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
1answer
11 views

Custom post type suppress transition from future to publish

I've scheduled a custom post type to a future datetime. Now I won't that it will be published automatically, instead it should switch the status to draft. We use this to pulish the webinars, so we ...
0
votes
0answers
26 views

WPML - Hook when language is switched (change user language)

I would like to change the logged in user's language (if someone is logged in) when they change the language in front-end. I'm using the WPML Multilingual CMS plugin in my Wordpress website. I've ...
1
vote
1answer
36 views

Wordpress action admin_post for non-admin authenticated users - Form submission

I'm trying to submit form using: `admin_post` && `admin_post_nopriv` actions. This is a shortcode for users search: add_shortcode( 'search_users', 'search_users' ); function search_users( $...
0
votes
1answer
20 views

Is it possible to apply_filter on a wp_ajax_ action?

I'm extending someone else's plugin with an AddOn and register it on their 'AddOn' page with an apply_filters .... (if possible) Their plugin works with Ajax calls on plugin page admin, so when I ...
0
votes
0answers
31 views

Nested Actions and Filters

It is possible and a good practice to combine filters and actions, it is necessary to take into account the order in which they are executed, a graphic example https://images.app.goo.gl/...
1
vote
0answers
22 views

Unable to change footer using wp_footer action hook

I am learning Wordpress from a book and while learning about how to use action hooks the author gives the below code . I am assuming this would change the footer at the front end . <?php ...
3
votes
1answer
18 views

enqueuing React script and hooking its target div fails to load script

I am getting a silent failure on the below code as I try to enqueue a static React.js script and hook its injecting div into the admin_footer. I see the page and my test echo plus the url of the ...
0
votes
1answer
14 views

add_action with associative array

I am trying to get these parameters from the do_action placed inside body: do_action( 'custom_action', array( 'product_id' => $product_id , 'outbiddeduser_id' => $outbiddeduser, 'log_id' =>...
1
vote
0answers
18 views

How to list all WC products by their attributes values?

I wanted to get some advice on how to list all my inventory attributes values. I have this simple code that will output the products as plain text, But instead of the_title(); I want a list of all ...
1
vote
0answers
26 views

Instantiating classes through add_action and saving them to user_meta data [closed]

In my Wordpress.com site I have a form where users can add relationships of different types (coworkers, friends, etc.) and each relationship type has different fields but similar functionality. I had ...
0
votes
1answer
24 views

trying to add extra field using hooks

I am trying to add an extra field on the backend menu of Edit Subscription menu (SUMO Subscription (plugin) -> List of Subscription -> Edit Subscription) I am sending you a screenshot for where ...
0
votes
1answer
18 views

Use action, filter, or hook to append HTML to WordPress plugin function

I am new to WordPress actions, filters, and hooks, and am wondering if it is possible to use one of the three to append some HTML to a defined plugin function using the theme's functions.php file. The ...
0
votes
1answer
20 views

How to show only specific category post by user role without plugin and restrict all other cats

I am using basic post for adding posts. 5 categories exist ( cat_A, cat_B, cat_C, cat_D, cat_E). And I have 2 custom user_role for registered visitors that is 'viewer_a' and 'viewer_b'. I need to show ...
0
votes
1answer
33 views

Use wc_enqueue_js only on specific pages - nested add_action

In my plugin, I'm trying to add inline script using wc_enqueue_js only on the cart page. The rest of the plugin is also executed only on the cart page. The code below works fine, but I don't like the ...
0
votes
1answer
21 views

Best hook for when a user session ends?

I'm creating a backend feature that calculated user's login sessions during the past 2 weeks. This is easy enough to do by incrementing a custom user field when the user logs in using wp_login: ...
0
votes
1answer
35 views

why require - does not load filter

I am using the boilerplate for WordPress plugin : https://wppb.me/ but I don't know if it's because of there coding this is happening. What I am trying to do is use require and load the below code ...
0
votes
1answer
51 views

add_action doesn't work for my function

I'm trying to build a function which run when a member is registering on my site. I am building an extranet using the Simple LDAP login plugin to use my LDAP directory so that users connect on the ...
0
votes
0answers
11 views

Check custom User meta before Insert

My goal is to check if my custom user meta field 'subscribe_to_newsletter' has been changed. If so i will be sending an API call to mailchimp to change the users status. I currently have a front end ...
0
votes
1answer
29 views

add_action('init') not work

my code is add_action('init', 'user_logged_in'); function user_logged_in(){ if( is_user_logged_in() && is_page('login')){ wp_redirect(home_url()); exit; } } the page slug ...
0
votes
0answers
23 views

How to find out the page name or slug inside a filter?

How do I find the page name or page slug inside a filter in a plugin? I am customizing a plug-in and I need to run some code based on which page is currently being displayed. The code is inside a ...
0
votes
1answer
14 views

Translate are not working for standard admin

I'm developing a plugin which uses strings of the "default" textdomain, but several strings will not shown translated. My locale language is "de_DE" (german). I try to access the word "Count", which ...
0
votes
2answers
58 views

W3TC manual cache flush does not work

My need is to have a .php file that is located in the root folders of all WordPress websites I manage, which can flush all cache of all sites. Therefore, I created a file "flush-cache.php" in the ...
0
votes
1answer
23 views

When does save_post hook fire on post save/update

In my plugin I want to update sitemap every time page or post is created/modified. To achieve this I use save_post hook: add_action( 'save_post', 'update_sitemap', 10, 3); Upon creating/saving/...
0
votes
1answer
18 views

how to use apply filter for Class?

Please do not remove the question saying that it's woocommerce. In the code below there is $fields = wp_parse_args( $fields, apply_filters( 'woocommerce_credit_card_form_fields', $default_fields, $...
0
votes
0answers
24 views

How do I remove an action hook inside a class that is called by another class?

Okay, so I am using the "FooEvents for WooCommerce" plugin for making WooCommerce products to events. And now I wanna replace their WooCommerce hook 'woocommerce_order_status_completed' with my own. ...
0
votes
0answers
23 views

Woocommerce - action to new order comment/note hook

I would like to send some other user the order notes once added by the admin in each order from wp-admin. So when admin adds a new comment on a order i would like to notify some users about it. I ...
0
votes
1answer
34 views

Passing function into add_action always returns the first argument

I'm building a plugin that iterates across and parses the arguments of various WordPress hooks, and because of the flexibility needed I'm passing a function as the callable parameter in add_action: ...
0
votes
0answers
38 views

How to use WordPress hooks in add new page with the Gutenberg UI?

I would like to add a custom link to the Add New Page > Page Attribute > Below or above the "Template Field". Please check my screenshot: http://prntscr.com/o3pjut Before Gutenberg, I simple used to "...
0
votes
1answer
41 views

WooCommerce: after install hook

There is some hook that is triggered after WooCommerce Install (I mean the WooCommerce Wizard, not the plugin installation)? I didn't found a hook to do this and the Wizard Class (...
0
votes
0answers
12 views

Usage of predefined actions in WP Cron

I have a working wordpress cron, that is executing as expected. Inside the cronjob I want to use the action plugins_loaded. /** * Daily event. */ public function ...
0
votes
0answers
19 views

help on a hook to hide one cpt category for users on a specific membership

I would like to hide one specific category of a classifieds plugin (ACADP) when submitting a classified using the plugin form, but only when the logged-in user is registered on the free membership. I ...
0
votes
1answer
17 views

Run a function on all posts

I have a function where I am counting letters in a title and adding that _product_meta_title key, everything is working fine when I am adding a new product but I have 500 products that don't have this ...
0
votes
2answers
44 views

add_action in wp_head accessible from class

Given this code: class test_class { function greeting() { echo 'Howdy! Test is successful!'; } function greeting_head() { //Close PHP tags ?> <?php ...
0
votes
1answer
41 views

Can not add admin notices from the edit_user_profile_update hook (notices not being displayed)?

Writing a little plugin my code is like this: add_action( 'edit_user_profile_update', 'sulock_save_profile_fields' ); function sulock_save_profile_fields( $user_being_edited_id ) { if(...
1
vote
1answer
24 views

wp_set_object_terms not updating database without a die()

I have added custom taxonomy to media attachments. From the individual post page these are updating correctly, with some tweaks to get the column count updating correctly - and I can see these changes ...
0
votes
1answer
22 views

how can I use add_action run another function when publishing new post?

I want to call my customClass when ever new post publish or update.but after I add add_action to my code , the function will run multiple times even before posting new post. can anyone help me? what ...
-1
votes
1answer
44 views

admin_post hook not working

I have this inside the <form></form>: <input type="hidden" name="action" value="submit_images" data-parsley-excluded /> I have this as my hook just to test: function maybe_add($...
0
votes
1answer
16 views

Adding php to form action breaks code [closed]

I have a form that is a button to link to a product but for some reason when I add php to the form action it's breaking the block of code. I'm not sure what I am missing. It's a very simple block and ...
0
votes
2answers
18 views

How can I see exactly what arguments are being passed through a filter so that I may modify them?

I'm having a great deal of trouble phrasing this. If I were to use the filter views_edit-page How can I see what exactly is being passed through the filter so that I may edit them? Normally I ...
0
votes
2answers
39 views

how can I use add_action with external class which the function contain 2 argument?

I create a file name custom.php which is like below: class customClass{ function dothisfunction( $mobiles , $message ){ //use parameters } } In my function.php file I add the ...
1
vote
2answers
70 views

What is the action hook for an order that fails on frontend checkout in WooCommerce?

I am working on a plugin that handles logic for when a user tries to checkout on the frontend and the order fails (e.g., person is using a credit card but it does not have enough balance to meet the ...
0
votes
0answers
18 views

Page not adding in admin using admin_menu action

I am trying to add a new page to the admin area: add_action('admin_menu', 'laksh_advert_menu'); function laksh_advert_menu() { add_menu_page( 'Advert', 'Advert', 'edit_posts', ...
0
votes
1answer
47 views

add action for wordpress query at a specific position

I wanted to allow users to put custom code to placed in between the wordpress query. say If I create a post query I want display an image in between--eg after 2nd, or after 5th post. is it possible to ...
0
votes
1answer
35 views

I don't understand how add_action and do_action work in tandem. The former executes the code already…what is do_action for?

I've tried reading the documentation and the definitions just elude me. I found this example that works here for my troubles -> https://stackoverflow.com/questions/50286549/how-can-i-store-the-values-...
0
votes
0answers
19 views

add_permastruct and wp_rewrite_rule on parent/children posts

So I am looking for a better way or the correct way to rewrite WordPress' url query mydomain?p=123 to show as mydomain/parent/child/ or mydomain/parent/child/gchild I have tried to force change the ...
0
votes
1answer
90 views

How to Remove a Filter from the Admin List Table?

I don't want the "Registered customer" filter option for the Admin Orders page. I have tried to search for how to remove it. I have been inside the WooCommerce codes to see how it's implemented. And ...
3
votes
0answers
28 views

add_meta_boxes action with refresh on save

I've created a meta box using add_meta_boxes action and it works when I open any post to edit it. add_action('add_meta_boxes', function() { add_meta_box( ... ); }); When WP auto ...
2
votes
0answers
66 views

How to use wp.hooks.addAction() in React JS [duplicate]

I am able to successfully use wp.hooks.applyFilters() and wp.hooks.addFilter(), but I'm not able to render a React Component using wp.hooks.addAction(). However, the console.log() runs just fine ...
0
votes
0answers
17 views

publish_post action callback not executed, why?

I create a custom post type and I insert programmatically a new post of that type with wp_insert_post with draft status. I need to send and email when in backend the post is published so I used ...
0
votes
1answer
24 views

add_action with variable as a part of the $tag string

I am trying to create meta fields to multiple custom taxonomy terms. I put the complete code inside a foreach but nothing is working. $taxs = get_object_taxonomies( 'product' ); foreach($taxs as $...