Questions tagged [actions]

A name for an event that is executed at specific points throughout the WordPress core.

Filter by
Sorted by
Tagged with
1 vote
2 answers
974 views

Calling plugin function inside custom plugin for onclick event

I want testFunction() to call check() that i created in my plugin php when i click My Button. How do i make it work ? <?php function createButton() { echo '<button onclick="testFunction()"&...
  • 111
0 votes
0 answers
86 views

Discern a specific plugin's action hooks

I'm new to Wordpress plugin development (but not to coding) so please excuse the question. I am trying to develop a plugin to catch user registrations and populate other web application databases ...
  • 103
0 votes
1 answer
191 views

post value to function with Ajax and jQuery

This is how you would create a custom smart tag in wp forms: function ea_custom_smart_tags( $content, $tag ) { if( 'my_smart_tag' == $tag ) { $value = 'Testing 1 2 3'; $content = ...
1 vote
1 answer
438 views

Inject HTML meta tag inside wordpress <head> tag using add_shortcode

I am trying to add some meta-tag when shortcode [refresh url='http://stackoverflow.com'] tag is used. I have done below code, but it is not working, I want to inject HTML code between "<head>" ...
  • 11
1 vote
1 answer
302 views

Adding custom fields to bbpress reply form

Referring to post "adding-custom-fields-bbpress-topic-form" with link https://wp-dreams.com/articles/2013/06/adding-custom-fields-bbpress-topic-form/, I want to add custom fields to bbpress reply form ...
  • 11
0 votes
0 answers
126 views

remove_action not working for a function

I want to remove specific function from wp_footer action. This is what I added in functions.php of my child theme. remove_action( 'wp_footer', [ 'Fusion_JSON_LD', 'print_json' ], 999 ); In this line ...
  • 469
0 votes
1 answer
33 views

Is_Page doesnt detect my page

I want to call Servicedeneme.php which is in main folder of theme, in mysite.com/faq/ It's title is FAQ so I write code for two form which are faq and FAQ.However, it doesnt work. I write below code ...
0 votes
0 answers
126 views

How do you insert code into the sidebar?

I would like to add code to the top of the sidebar. When I do: add_action('get_sidebar', 'function') It adds above the sidebar DIV. I would like to insert inside the DIV. If I do: add_action('...
0 votes
1 answer
29 views

How Do I Unhook This Parent Theme Function?

In a parent theme I have a function like this, that removes hyperlinks from comments: function preprocess_comment_remove_url( $commentdata ) { //some code... return $commentdata; } ...
0 votes
1 answer
88 views

save_post_{$post->post_type} action firing on second save

I have custom metabox checkbox on CPT in my plugin. I want to fire an action and save new option when I save this post. But no matter how many times I tried it's saving option value only on second ...
  • 113
0 votes
1 answer
287 views

admin_notices is not working inside function

I am creating a plugin . But when I trying to call the add_action('admin_notices','my_test_notice_1'); inside a function its not working. I need to call the add_action('admin_notices','...
0 votes
0 answers
104 views

Hook to add content after date in post?

This code function test($the_date) { return $the_date . 'after'; } add_filter ('get_the_date' , 'test'); adds 'after' after the date, which is what I want. But it adds it inside the date link tag....
0 votes
1 answer
429 views

Adding code before post title with the_title produces weird results

add_action ('the_title' , 'test'); function test($title) { $mycode = '<div>test</div>'; echo $mycode . $title; } I expected this functions.php code to add "test" before the ...
1 vote
1 answer
208 views

How can I trigger actions manually?

I am working with Gravity Forms and the Webhooks Add-on, but those may or may not be relevant to my question. If I have an action defined with a hook in my functions.php file, is there an easy way of ...
1 vote
0 answers
92 views

remove_action returns false regardless of priority

I am writing my own plugin to customize a public plugin. My plugin is doing this customization by removing an action via remove_action() and adding it back with my customized code. The code below ...
  • 31
0 votes
2 answers
15 views

Make a treatment before the action of the form

I have a form that redirects to a payment platform and sends data in $_POST. <form method="POST" action="https://www.paiementgateway.com/paiement/order1.pl" accept-charset="UTF8" id="knp-form" ...
0 votes
0 answers
1k views

Parameters in woocommerce_before_add_to_cart_button hook

I need pass parameters to woocommerce woocommerce_before_add_to_cart_button hook. In my functions, I have a function that calls: /** Yiith: evitar pagar dos veces por el mismo depósito, obliga a ...
  • 3
0 votes
1 answer
46 views

Use another action instead of the shortcode API to display the last time a user logged in

Here's my problem: if ( !class_exists( 'printSecurity' ) ) { class printSecurity { public $constant_name_prefix = 'PRNSEC_'; public function __construct() { define(...
0 votes
1 answer
190 views

Call to Action Button - Resize Help [closed]

I need help with resizing the "free quote" action button on my website. It is placed on the menu on the right top corner. I need to resize it to smaller size so that it fits the size with other text ...
0 votes
0 answers
345 views

Is update_post_meta used when save_post action hook is invoked?

Here, I have some code which applies some indexing operations on an external service (Algolia). My purpose, is to index posts in a similar way, as described in their API documentation. For that cause, ...
1 vote
1 answer
142 views

How to check current user before all actions and filters?

I am working on a plugin with 50+ actions and filters. All actions and filters only apply to users with a specific user meta (b2b). I want to check this user meta before everything How can I do this? ...
2 votes
1 answer
283 views

WP action is not triggering a do_action() call within?

Okay, so I have a plugin on my site that triggers a do_action(). In a second plugin, my custom plugin, I hook into this action and end up calling a do_action() for another custom action of my own. ...
1 vote
1 answer
1k views

How to add custom script to the particular Product Category page

I am trying to add the script to the particular Product Category page, but the code is not adding it to the category. Page (working): function wpb_hook_faq_javascript() { if (is_single ('8') || ...
1 vote
0 answers
730 views

Contact Fom 7 - how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?

Contact Fom 7 - how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control ? Using the 'Query Monitor' plugin I found that the HOOK which I need to ...
  • 111
-1 votes
2 answers
113 views

Where can I find the "add_action()" inside a theme?

I'm developing a WordPress plugin for a site that is using the theme ColorMag. The plugin uses the_content() to insert some content in a page. When I put the plugin in other test site, the content is ...
0 votes
0 answers
163 views

Custom filter from post meta

I am trying to create a dropdown filter on the custom post type record listing page. I have it showing up using a dummy array but can't get it to work with actual data. function ...
1 vote
1 answer
2k views

WordPress Custom Shortcode Conflicting with Media Library

I have written a small function that displays a Custom Post Type called Testimonials (in my case) using a shortcode. The Shortcode runs properly. But I noticed 1 major problem with that. My ...
  • 33
1 vote
1 answer
136 views

How to manage arrays from custom functions stored in functions.php?

In functions.php I have made the following code: add_action( 'listofnames', 'SomeNames' ); function SomeNames(){ $names=array( "john","edgar","miles"); return $names; } It should return array I ...
0 votes
1 answer
29 views

I want to hide "sold by" on certain pages with id page 43

I want to hide "sold by" on certain pages with id page 43 if I use this code, it's hidden for all pages on my site / Remove sold by in product loops / remove_action ('...
0 votes
1 answer
76 views

cannot filter after using pre_get_posts

I am using pre_get_posts() in the backend for a custom post type screen where all the records are usually displayed. The action I have is showing only posts for today's date. This is working fine ...
0 votes
0 answers
105 views

How to remove default action from a plugin?

I'm trying to remove the default wordpress action: add_action( 'do_pings', 'do_all_pings', 10, 1 ); from wp-includes/default-filters.php This is the code I have (plugin): add_action( 'init', '...
1 vote
1 answer
43 views

Which action is triggered when a theme was modified?

I want to intercept plugin changes, but no action hook listed in the Action Reference seems to do it. I tried after_switch_theme which is triggered only after changing from one theme to another, and ...
0 votes
1 answer
252 views

New bulk action to resend welcome emails

I have added a new custom bulk action to the user listing page called Resend Welcome Email, it is showing and running. What I'm looking to do is fire the Resend Welcome Email plugin's action. I'm ...
  • 15
0 votes
0 answers
44 views

Removing Plugin Action via Theme for Non-admins

add_action( 'plugins_loaded', 'mytheme_remove_show_my_balance' ); function mytheme_remove_show_my_balance() { if ( !current_user_can( 'administrator' ) ) { remove_action( 'personal_options', ...
0 votes
0 answers
15 views

When calling a function with admin-ajax.php, what is the first parameter? [duplicate]

I'm trying to make a function that can either be called directly or via admin-ajax.php. Strangely, when calling it as an AJAX function, the first parameter's value is a blank string. function ...
0 votes
1 answer
40 views

Adding JavaScript file in Admin Panel

I am learning WordPress plugin development. I am trying to attach a jQuery/JavaScript file in Admin Panel. I am using below code in plugins index.php file. function admin_script() { ...
  • 397
1 vote
1 answer
74 views

Adding buttons to Add New Post and Add New Page

I want to add a button in Add New Page and Add New Post pages. Here are places I want to add items: New page's sidebar (next to Page Attributes). New post's sidebar (next to Post Attributes). New ...
  • 13
1 vote
0 answers
76 views

Set a custom display_name on user_register?

I'm trying to force a specific "display_name" using data collected in a wpforms registration form. In the registration form, I've got a field for "last name in high-school" and a field for "nickname ...
  • 45
0 votes
1 answer
718 views

How to position user meta data field

I have 1 additional field I want to display on the user profile page (mainly admin users will use this) I have done it but it is showing up at the very bottom of the page, I want it to sit in the ...
0 votes
2 answers
356 views

do_action not working in loop

I've been using do_action to generate multiple action hooks in the loop. It seems unlucky for me the do_action not working. function ltc_generate_input_fields($fields = array()) { echo "Hello ...
0 votes
1 answer
407 views

How to change lost password email text using custom plugin wordpress?

In wordpress, i want to add one extra parameter(ABC) in lost password link with key (lost password email text). I have added many hooks. add_action( 'password_reset', 'password_reset_hook', 10, 2 ); ...
0 votes
1 answer
242 views

What's the correct way to add capabilites to user roles?

A third-party plugin adds the capability 'edit_booked_appointments'. I'd like to assign this capability to the already existing user role 'editor'. I created the following function in my child theme: ...
  • 3
0 votes
1 answer
172 views

How do I dequeue js/css at the last possible moment?

I'm trying to dequeue the font-awesome stylesheet included with the ninja forms plugin (because I manually include the latest FA via a CDN). I did this: add_action('wp_enqueue_scripts', function () {...
  • 301
0 votes
1 answer
50 views

Get original value in save_post action hooka

I'd like to get the original value of the $post on the save_post action. This way I can detect changes, and only do specific actions if the post content/title was changed. Is this possible?
  • 396
2 votes
1 answer
2k views

Unable to programmatically remove product from WooCommerce cart

I'm using WooCommerce. For certain conditions, I'll want to remove a specific product from the cart. I feel like I'm using the correct method of doing this, but for some reason it's not working. Other ...
0 votes
1 answer
24 views

Add back in child theme what the parent theme removed with remove_action

My parent theme removes the emoji fallback script that makes emoji show up as images: // parent theme's functions.php remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('...
  • 111
1 vote
1 answer
50 views

Save User Meta Email Address in Lowercase

I'm looking for a way to save all email addresses to user meta as lowercase, ideally without validating and asking the user to change it but instead just saving it as lowercase. I've got as far as the ...
2 votes
1 answer
190 views

How can I add data to a custom column in the Users section of the wordpress backend?

Can anyone help me with adding data to a new User table column that I added? In the wordpress backend, in the Users section, I added a custom column called "Last Name". Now, I'd like to add last ...
  • 189
2 votes
1 answer
80 views

Explanation for remove_filter used in the below code [closed]

I am very confused about what the developer has done here. This is inside a class..a filter has been added and then removed, added again. This code results in many errors as well. add_filter('...
's user avatar
1 vote
0 answers
83 views

How do I use remove_action on an add_action that uses an array?

This is a messy question :) I'm running into a conflict between plugins and need to disable one (WP Bakery) on the front end of certain pages. I'm looking at multiple questions on how to disable a ...

1 2 3
4
5
29