Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [actions]

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

0
votes
0answers
19 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
17 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
16 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
15 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
3answers
31 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
31 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
23 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
21 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
25 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
0answers
18 views

Post request in add_action [on hold]

I'm quite new in wordpress so excuse me if i miss things. I'm running my wordpress in localhost for now , and i use the WpManageNinja Fluent Form : https://wpmanageninja.com/wp-fluent-form/ . They ...
0
votes
1answer
15 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
16 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
35 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
32 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
12 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', ...
-1
votes
0answers
42 views

How does WordPress know to handle both function & class methods when doing actions?

Assume you add_action with both a function and a class method. How does WordPress know to handle them? add_action( 'init', function() {} ); add_action( 'init', [$this, 'methodName'] ); add_action( '...
0
votes
1answer
43 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
29 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
17 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
47 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 ...
2
votes
0answers
23 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
63 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
14 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
20 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
44 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
45 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
34 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
29 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
38 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
19 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
25 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
99 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
0answers
36 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
20 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
13 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
38 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 ...
1
vote
1answer
26 views

Which hook should I use to capture $_POST('password') via profile update and password reset

I need to rehash the password which the user entered during Wordpress registration (I use WooCommerce) I'm successfully able to do this with the following: add_action( 'user_register', '...
0
votes
2answers
38 views

WordPress ajax-action how to return content

So I'm trying to set up an AJAX action for a plugin I'm building. When using /wp-admin/admin-ajax.php?action=beacon_podio-get_apps I was just getting hello world0 and I'm not seeing Request is ...
0
votes
3answers
28 views

add_action where function has arguments

I have a general question about functions and add_action to it. I have a function and adding an action do it. But how can i define a value for the argument on this action? add_action( '...
0
votes
0answers
15 views

Can we execute a function when Gutenberg block is added?

I'm wondering if there is a way to execute a function when a certain block is added in the editor, but not each time we edit the block. As far as I know the only functions we can specify are edit and ...
0
votes
2answers
46 views

Add HTML code before the title of the Tag page

I want to show an iframe at the top of a specific Tag page, so once I have is_tag('my_tag'), I will add the iframe before the title of the page. I've tried this code to show the iframe before the ...
0
votes
0answers
16 views

Button bulk action

Hi! When i press myAction button i want to trigger an action from bulk drop down.Can someone help me? Thanks in advance!
3
votes
1answer
27 views

How to show more posts on an archive page?

I'd like to show more posts on my custom archive page, but can't seem to figure out the right way to do it. Currently it displays 10, which is the number set in WP Settings and the number I'd like on ...
0
votes
2answers
49 views

How to run a function after wp() in the wp-blog-header.php file?

I want to run a function after the wp(); line in the file wp-blog-header.php, what is the proper hook to use here? <?php /** * Loads the WordPress environment and template. * * @package ...
2
votes
2answers
39 views

Unable to show error message using wp_login action

My goal is to show an error message when i check if the user is locked or not, the problem is that when the function ends, it redirects to the page that must appear after succesfull login. Objectives:...
0
votes
2answers
27 views

How to call a function or method that is Namespaced using another plugin

I'm using an action from one plugin that needs to call a function from another plugin. That function is name spaced. Typically, I would use something like: add_action( 'hook_name', 'function_name' );...
0
votes
0answers
224 views

Is there a way to disable ajax add to cart for specific products on single product pages

I would like to disable ajax add to cart for specific products, products that have add on's enabled by the Woocommerce product add on plugin as ajax add to cart is not compatible with products using ...
2
votes
2answers
37 views

Fire jQuery function when post edit screen loads

Trying to get this function to work. But keep getting a jQuery not defined error. I have tried many variations here to get the jQuery to work: https://blog.templatetoaster.com/fix-jquery-is-not-...
0
votes
0answers
29 views

WordPress Plugin Boilerplate - add actions and/or filters based on user's role

I am developing a plugin using WordPress Plugin Boilerplate. Some of its functionality need to be available only when a shortcode gets resolved in a page and furthermore some of it only if a user is ...