Stack Exchange Network

Stack Exchange network consists of 174 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

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

-1
votes
2answers
36 views

Using add action for class with construct

i have this i answer in reference but seems have upvoted by many https://wordpress.stackexchange.com/a/48094/145078 but not sure why it is not working for me.. in answer class MyClass { ...
1
vote
1answer
18 views

Use debugging for add action events

Is it possible to vardump the variable inside the action function? i am not able to echo or see results when i am doing so. This is not a woo commerce question but i am having problems with ...
0
votes
0answers
10 views

Intercept password prior to wp_update_user committing and hashing?

I'm using a plugin that uses wp_update_user instead of password_reset and I need to use the password prior to hashing to sync the change to a secondary authentication system. Is there any way to do ...
0
votes
1answer
20 views

Hook into all password resets in Wordpress and get password before hashing?

I'm syncing my Wordpress authentication system with an secondary/external authentication system and my site has at least two ways of resetting the password, including: Password reset email User ...
0
votes
1answer
15 views

Add Action wp_update_post not Updating WYSWIAG editor

When we use the wp_update_post function, and do a pre_post_update action, it gets updated in the database, but the WYSWIAG editor shows the revision just made, not the processed one. For example ...
1
vote
0answers
20 views

Check Title Unique Or Not and If not error message and dont save

i am get tired from searching 2 days for what i wanna i have 'area' custom post type have Title and another field i wanna the title of area is unique if the user enter title 'area1' and this title ...
0
votes
0answers
27 views

Remove action added in plugin class from theme

I am trying to remove action that is added via plugin in my theme. The below plugin class creates a portfolio page template but I don't want this page template in my theme. Is there any way to unhook ...
0
votes
1answer
31 views

WooCommerce Hook: Content get's displayed twice and not AFTER the order total

I've overwritten WooCommerce's review-order.php to change the checkout a little bit. Now everytime I add something to the hook woocommerce_review_order_after_order_total the contents get displayed ...
1
vote
2answers
47 views

Set meta field to publish date + 2 weeks

I have a meta field called postexpiry, and I want to set the value to the publish date, + 2 weeks. So if today were October 3rd, I want the field to be set to October 17th. I was thinking about ...
0
votes
0answers
14 views

wpdb->insert creates duplicate rows

mypage.php $create_args = array( "user_id" => get_current_user_id(), "description" => "Your order #".$order_id." has been successful" ); do_action('...
0
votes
1answer
8 views

woocommerce_new_product action doesn't fire

I am trying to run a function every time a new product is added on woocommerce, for so I am using woocommerce_new_product action. For this I add a new action function uniqueNameFunction($id) { ...
0
votes
2answers
43 views

Woocommerce - Adding row to cart table

I would like to add an extra row to the Cart Table in Woommerce, but I can't find the right action. From this file https://github.com/woocommerce/woocommerce/blob/master/templates/cart/cart.php, I ...
0
votes
0answers
27 views

add_action don't updates theme layout when using values from the WordPress customizer

I am trying to control the order of the information displayed in the WooCommerce single product page via the customizer with a sortable control. The user can select if the different elements are ...
0
votes
1answer
32 views

Static var overwritten with WP AJAX action, works fine without AJAX

I'm working on a script that will be used to show a progress bar when large amounts of data are exported. For this to work you need to know how many location you have in total, and keep that number ...
0
votes
0answers
18 views

Why should I need to add init action to include PHP file to WordPress Plugin?

I wanted to include a PHP file to my plugin. So I added following code to top of my plugin. require_once( plugin_dir_path( __FILE__ ) . 'inc/test-file.php'); But it didn't worked. Then I tried ...
0
votes
1answer
48 views

400 Bad Request - JavaScript App calling Custom wp-json endpoint

I have successfully created a new endpoint/route and can view it via wp-json. Not only that, I can successfully make a post request to this endpoint externally from the browser using the Restlet ...
0
votes
1answer
26 views

How to change form action of wp-login page with a function

I'm manually creating my own Wordpress login form. The action parameter of all the forms points to wp-login.php. I want to change it for all of them to custom url (/login). Any idea how to that? For ...
0
votes
0answers
20 views

adding an action inside if condition not working

This is my function $enable = false; //if false is provided then the action should run and remove the breadcrumbs if($enable ===false){ add_action( 'init', 'woo_remove_wc_breadcrumbs' ); ...
0
votes
0answers
35 views

get_permalink() is not working after published

I created a plugin that, when updated, gets a link to a published record and sends it to the API. So I get the URL, but sometimes wordpress gives me such a link: site.com/?p=123, and should site.com/...
2
votes
1answer
35 views

Flush Rewrite Rules on init or rest_api_init?

if I'm using the REST API to create endpoints in my plugin, should I be flushing rewrite rules on init or in rest_api_init? I realize that it should be done on plugin activation/deactivation. However,...
0
votes
0answers
16 views

Overrided parent function in child theme not load next content

So I want to change top header line display. To do that I'm trying to override parent theme function with my edited function. When I do that my function override parent function, but next page content ...
-2
votes
0answers
30 views

Capture WooCommerce Smart Coupons in Zapier

I'm using WooCommerce Smart Coupons to automatically generate coupon codes whenever a specific SKU is purchased. This coupon code will then show up in the customer's order receipt. I then capture the ...
0
votes
0answers
16 views

Woocommerce add a text field if specific option is selected

I need to make active/visible a new filed before 'Add to cart' button, only if user select a specific option. The case is simple: I sell t-shirt with options: "Small", "Medium", "Large", "Size upon ...
0
votes
1answer
17 views

wp_update_nav_menu also triggers post_updated

I have built a little script that indicates if one specific element should be taken from a cache instead of a query. I started with an action triggered after each post update like this: function ...
0
votes
0answers
10 views

Trigger action via button

I am using wordpress 4.9.8 and PHP 7.1.8 I have added a button to the new post screen: I am trying to trigger the button the following way: add_action( 'media_buttons', 'add_my_media_button', 99 ); ...
0
votes
1answer
25 views

Remove action from plugin

I'm trying to remove an action in edit_user_profile from a plugin. But I don't know how to do, This is add_action from the plugin : https://github.com/jaredatch/Basic-User-Avatars/blob/master/init.php ...
0
votes
0answers
16 views

which hook do I use to present a message to the user when he adds an image in a post by a URL

I will make a code that when the user tries to put an image via URL without the HTTPS will present an Error message, however I do not know which hook to use, the error would have to appear in the ...
0
votes
1answer
22 views

I don't understand why I need a lower priority to remove an action with a higher priority to make it work

In the section about Priority of the WordPress documentation is stated: A function with a priority of 11 will run after a function with a priority of 10; and a function with a priority of 9 will ...
0
votes
1answer
32 views

How to remove an action added by a child theme of Genesis

I developed a child theme for Genesis that adds Bootstrap on top of it. In the core of this child theme I edited the way the category is displayed in the post, putting it above the title. Now, I'd ...
3
votes
0answers
29 views

Make default new sites https (multisite)

Quick background case: If I use Softaculous to install WP in cPanel, I can specify which protocol I would like the site to be in... (so they have something that addresses this). However with my ...
0
votes
0answers
54 views

Unhook a function within a class in the child theme

I am using Hestia theme and I want to unhook the function that displays footer copyrights to replace it with my custom function, I tried the remove_action() in my child theme functions.php but it didn'...
0
votes
1answer
17 views

{status}_{post_type} does not run correctly?

I used the hook {status}_{post_type} from the docs here. In the docs it said: action will execute when a post of type {post_type} transitions to {status} from any other status. Here is my code: ...
10
votes
4answers
148 views

Is there any action filter/hook for validating a custom field before publishing the post?

I have a custom filed called xxxx_url. xxxx_url should be unique. So, before publishing the post, I want to make sure that xxxx_url is unique or not? If it isn't unique, publishing the post should be ...
0
votes
1answer
20 views

Is dynamic action name building a bad practice?

I'm looping through some posts to delete them: /** * Holds deletion errors. */ $errors = []; foreach( $imported_posts as $imported_post ) { $post_id = $imported_post->ID; /** * ...
0
votes
1answer
15 views

Notify admin when Custom post meta data gets updated or deletet

I am trying to email admin when an single custom post meta gets updated or deleted. This does not work with post save or post delete. All i need is to detect when this post meta gets updated or ...
0
votes
1answer
25 views

How to direct user after comment save

I've been trying to direct the user to the specific page after they posted the comment, but that not luck for me. Here is the my code blocks My first try: add_action('wp_insert_comment', array($...
2
votes
1answer
40 views

Modifying values with add_action to be sent to db

I am struggling with this problem for hours now, what is going on is that somewhere before inserting the values into the db, this action is being called. do_action_ref_array('h5p_alter_user_result', ...
2
votes
1answer
110 views

How to remove_action inside class [duplicate]

i have class like this if ( ! class_exists( 'My_class' ) ) { class My_class { public function __construct() { add_action( 'woocommerce_shop_loop_item_title', array( $this, '...
1
vote
0answers
23 views

Get Time Taken By Each Action Hook in Wordpress

I am developing a Plugin, and want to record Time taken by each Action Hook, I am able to get all the Hooks Triggered on a Page with the Action and Priority, but i am unable to get the Time taken by ...
0
votes
0answers
13 views

When would it be best to hook AJAX functions on a back-end page?

I'm setting up my page as follows: add_action( 'admin_menu', [$this, 'addAdminMenu' ], 80 ); And its content: public function addAdminMenu() { $this->hook_suffix = add_theme_page( ...
0
votes
2answers
103 views

Get The Caller (Plugin / Theme / Core) For All actions & Hook in Wordpress

I am developing a plugin which will show the caller of all the Hooks & Actions on a Page in Wordpress just like QueryMonitor. I know that global $wp_action & $wp_filter has all the information ...
0
votes
0answers
17 views

How to roll back a wordpress plugin update via PHP function

I'm wordpress developer and want to add roll back to previous version or some other subversion inside one of my plugins. I tra to Google this but neverfind workable solution. Do anyone have idea how ...
0
votes
1answer
172 views

How can I add an additional action button into the woocommerce admin order page?

I am using 'woocommerce_admin_order_actions' hook to add an additional action like Invoice. But it is repeating many many times whereas others button are repeating once. public function ...
1
vote
1answer
29 views

Write automatic title at save_post (infinite loop)

I want to write the post title with the content of a custom field $sentence_number, this way: add_action('save_post', function ($title, $post_id) { $post_type = get_post_type($post_id); if ($...
0
votes
2answers
46 views

get gravity form ID from backend/wordpress admin

I want to add a filter to a form submission like it is done here. add_action('gform_pre_submission_6', 'capitalize_fields_6'); function capitalize_fields_6($form){ // Code here } My question is, ...
0
votes
1answer
112 views

How to run an add_action hook for specific page

I have a function that loads a script for validation and i want to add it for only 'login' page. this the function: function include_regForm_validation() { wp_register_script( '...
1
vote
1answer
18 views

Is there way to run a code every time when any cron is run?

publish_post is an action triggered whenever a post is updated and its new status is "publish". Is there similar action which is trigger when cron is run including WordPress default crons? I am ...
1
vote
2answers
92 views

Why The Init Hook For Custom Post Types

I have a question about this documentation. Why would I register a Custom Post Type in the init function as the docs suggest? Is this only if I am not using a plugin? As I understand it, init runs ...
2
votes
1answer
44 views

save_post vs post_updated

I'm new to WordPress and php. I would like to write a function that triggers when a specific post has its content updated. I came across 2 actions, save_post and post_updated. I'm a little confused ...
1
vote
2answers
81 views

Unable to prevent function using save_post firing twice

I am using save_post for a function to send an email when a post is updated by a user. This is firing twice and I am aware this is due to the post revisions and autosaves. I have tried to prevent ...