Questions tagged [actions]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
32 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
57 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
34 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
38 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
62 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
15 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
73 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
27 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
18 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
104 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
113 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
28 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
42 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
47 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
60 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
42 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
64 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
13 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
25 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
19 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
59 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
89 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
45 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
33 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
57 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
19 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
21 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
50 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 ...
2
votes
2answers
362 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
34 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
54 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
108 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
21 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
257 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
36 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
74 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
18 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
30 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 $...
0
votes
3answers
105 views

Error call_user_func_array() expects parameter 1 to be a valid callback when using image_size_names_choose

I'm using the example from add_image_size() | WordPress Developer Resources to try to add custom image sizes to the admin media selector. add_filter( 'image_size_names_choose', 'my_custom_sizes' ); ...
0
votes
1answer
50 views

Remove an action added within a class in a WordPress plugin

I'm trying to replace a function in a WordPress plugin (Easy property listing) without success at the moment. The action is added like that, in a class : <?php /** * Search Object * * @...
0
votes
1answer
43 views

WordPress set featured image to first image of the post

I have tried every solution from similar answers and nothing seems to work on Wordpress 5.0 + When saving a post I want to set its featured image to the first image in the post content. function ...
0
votes
1answer
43 views

Postback redirect through add_action is not triggered

template: <form action="<?php echo esc_url( admin_url('admin-post.php')); ?>" method="post"> <input type="text" name="boo" id="boo" required> <input type="hidden" name="...
4
votes
1answer
59 views

What is the earliest possible hook for safely using `is_front_page`?

When a page request is made, at what point does is_front_page start working? As I recall, if you try using it too early it will always return false. My assumption is that the wp action is the first ...
0
votes
0answers
36 views

profile_update hook does not fire from front-end

I'm using BuddyPress to allow users to log in on the Front end. Once logged in, they can click on 'My Account'. On this page they can upload avatars, edit their account information, etc. When I ...
1
vote
0answers
191 views

Save acf field data via acf/save_post before post is saved

I have 4 advanced custom fields and I would like to save each field value when it is changed on the post and not have to wait until the post is saved. I'm using acf/save_post action. Here is my code ...
1
vote
1answer
425 views

Remove action on product archive page [closed]

I have a product description which is hooked into my product archive page in the following way by my theme (The7): /** * display short desc hook. * * @hooked woocommerce_template_loop_rating - 5 *...
0
votes
1answer
235 views

a weird attribute on every html tag

me and my friend working on a Wordpress site but we see it differently on our machines, He sees a weird attribute wfd-id="" on every html tag in google console when he inspect it, also I loaded ...
0
votes
2answers
22 views

How to pass argument to add_action while the method is inside a class?

in my functions.php I have require 'autoloader.php'; add_action('init', 'MyClass::make'); and in my MyClass class I have class MyClass { public static function make($type) { var_dump($...
1
vote
1answer
15 views

How to Use Parameters with a Do_Action Function Within PHP Tags

I'm using a WordPress plugin that allows integration actions to integrate it within a theme. Using GeneratePress' Elements feature, I'm adding the action as a hook. Currently the code I'm using is: &...
0
votes
1answer
63 views

password_reset doesnt work

Im trying to use $_POST method after password reset submit action here is the code add_action( 'after_password_reset', 'action_function', 10, 2 ); function action_function( $user, $new_pass ){ if ...