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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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

2
votes
1answer
37 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
88 views

How to remove_action inside class

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
21 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
31 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
36 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
24 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
41 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
51 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
17 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
52 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
32 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
33 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 ...
1
vote
2answers
29 views

wp_transition_post_status does not change the status of the post

For some reason, I have to unpublish certain posts every time wordpress loads. This is my code: function af_change_post_status() { $notpayed_posts = new WP_Query( array( 'meta_key' ...
1
vote
1answer
23 views

How to change the order (priority) of registered filters (or actions) (e.g. for the_content)?

Is there any way to change the order of filters for e.g. the_content before they are applied? What I currently have is the following ideas: /** * Print all filters for some hook. */ function ...
1
vote
1answer
44 views

Detect when any plugin is activated or deactivated

I have a starter theme I use for most websites I built myself. Because each site has different plugin dependencies, I'm trying to create a script that essentially collates a list of all plugins ...
0
votes
0answers
28 views

add_filter not works in ajax

I edited my woocommerce loop products with remove_action and add_action functions. And create ajax infinite scroll. I created woocommerce.php and put all my action functions to it. And called ...
0
votes
0answers
35 views

How do I trigger a post update within a get_posts() foreach loop?

I am using plugins that fire action hooks before and after a post save. When a post is saved the functions hooked into those actions perform some calculations and put the results into a custom field. ...
0
votes
2answers
38 views

Payment before publishing post

I want my user pay before every post publishing. I searched for some hooks that triggers before a post publishes, but all these hooks run after a post is successfully published and i don't want this. ...
0
votes
0answers
11 views

Correct action to use on Custom Post Type creation with custom status

We have a custom post type with custom statuses. I am trying to hook into the moment that a post is created and updated. The idea is to send an email when the post is created and another email ...
0
votes
1answer
29 views

How to remove a class function from a plugin by using remove_action()?

Result of the var_dump('parse_query'): WP_Hook::__set_state(array( 'callbacks' => array ( 10 => array ( '...
2
votes
2answers
24 views

Redirect users on specific post category or category page

im trying to redirect users on specific categry with this hook: // Show app-data posts only to app users function user_redirect() { if ( is_category( 'app-data' ) ) { $url = site_url(); ...
0
votes
0answers
21 views

Action 'save_post' not working for quick edit

I have read other answers to similar questions but none of them solved my problem. This code works great in Editor but on Quick Edit or Bulk Edit it does not appear to fire at all. What am I doing ...
0
votes
1answer
100 views

Filter WooCommerce archive pages by an additional category

I'm working on a WooCommerce bookstore site with a custom taxonomy.php template that generates different archive pages based on a category called "Highlights". So, for example, there is a "Best ...
0
votes
0answers
12 views

How to store additional data that is related to core data

Long story short, I am going to be building a web application with WordPress as the framework. We have to use WordPress, I cannot suggest a different framework. The application will have users with ...
1
vote
2answers
38 views

Search function works improperly

So I am trying to edit my Search so it searches only for specific categories. I am adding this code to my functions.php file in child theme: function searchcategory($query) { if ($query->...
0
votes
1answer
21 views

Using add_filters() , apply_filter(), add_action() and do_action() in extending a plugin

Suppose i am developing a plugin that is related too booking.Next time i want to add an add-ons on that plugin for payment.Then i added another add-ons for paypal payment. Assume that below is the ...
1
vote
2answers
36 views

How to change the blog title with add_filter? details below

i want to add a prefix to all the blog title by modifying the all ready applied filter . when i searched i got this: apply_filters( 'single_post_title', string $post_title, object $post ) what ...
1
vote
1answer
19 views

WP_Query ignoring tax_query when is_singular

I’m trying to set up some post permissions using taxonomies and I'm applying my rules in a pre_get_posts action. It’s working fine when multiple posts are found, but in class-wp-query.php near line ...
0
votes
0answers
40 views

Contact Form 7: filter / action to replace form content

I wrote a plugin where I use a function to replace the form tags for certain forms: add_action('wpcf7_before_send_mail', array( $this, 'changemail'), 10, 1); The function gets the form by name, and ...
0
votes
0answers
12 views

plugin to show related posts under current open post according to user spesifications

I want wordpress plugin to show related posts under current open post according to user specifications on control panel : user can determine the title of featured posts under current open post user ...
0
votes
0answers
29 views

add_action works just with some hooks

/** * Show consent checkbox in checkout * * @param $checkout * * @since 1.1 */ public function checkout_consent_checkbox( $checkout ) { $privacy_policy_strings = Controller_Menu_Page_Wc::...
0
votes
1answer
41 views

remove_action - pre_get_posts - does not restore original query

I have following functions ... function ajax_sortposts() { global $wp_query; $sorting_order = $_POST['sorting_order']; if ( $sorting_order == 'Latest' ) { remove_action( '...
0
votes
1answer
47 views

Why does my wp_safe_redirect output the ERR_TOO_MANY_REDIRECTS error?

I've built a demo page and now I'd like to redirect on it whenever an user logs in and hasn't set up his theme, my code being: function add_admin_page() { if ( empty( $_GET['page'] ) || $_GET['...
0
votes
0answers
57 views

Change hook to add_action in a plugin class

<?php namespace wp_gdpr_wc\controller; use wp_gdpr\lib\Gdpr_Container; use wp_gdpr_wc\lib\Gdpr_Wc_Translation; use wp_gdpr_wc\model\Wc_Model; class Controller_Wc { const REQUEST_TYPE = 3; ...
2
votes
2answers
41 views

Remove action from a plugin class

<?php namespace wp_gdpr_wc\controller; use wp_gdpr\lib\Gdpr_Container; use wp_gdpr_wc\lib\Gdpr_Wc_Translation; use wp_gdpr_wc\model\Wc_Model; class Controller_Wc { const REQUEST_TYPE = 3; ...
4
votes
1answer
188 views

Does WP fire delete_post when trashed posts are automatically deleted?

I have a custom db table that stores additional post data and I need to delete posts from my custom table when the original post is deleted. Will WP fire the delete_post action below and run ...
0
votes
0answers
25 views

How to call wp_ajax_ type actions only from a specific page?

Till now, I'm including a script (say utils.php) in functions.php, and that script contains: add_action('wp_ajax_myaction', 'do_things'); add_action('wp_ajax_nopriv_myaction', 'do_things'); It all ...
0
votes
1answer
70 views

add_action template_redirect not working for home page

I am using bimber theme on latest wordpress. I wanted to force all frontpage views behind a login and added the following code in bimber's functions.php function members_only() { // Check to see ...
0
votes
1answer
39 views

add_action init breaks site on PHP 7.1

If there's no child theme available, I use a custom plugin for some minor changes. The following code for hiding update notifications etc. has always worked perfectly. However, if I switch from PHP 7....
0
votes
1answer
19 views

Automatically set post_parent value

I'm trying to set my blog posts as children of an /articles/ page. The URL structure is correct, but the breadcrumbs are not. If I manually set the post_parent column in the database to the /articles/...
1
vote
0answers
22 views

Are functions in main plugin file called before function bound to register_activation_hook runs?

In my plugin, I am doing a minimum-supported PHP version compatibility check via a function bound to register_activation_hook and halting activation for those on PHP version less than the minimum ...
0
votes
1answer
19 views

taxonomy_edit_form_fields output after term fields

I'm using the following code to create a custom metabox on a custom taxonomy page. $term_filter_name_edit = $type . '_edit_form_fields'; add_action($term_filter_name_edit, 'box_term', 1000, 1 ); ...
0
votes
0answers
35 views

wp_ajax add_action fuction won't fire on custom jQuery action

In general, I try to apply a "load more post" functionality to a loop, but I am failing to fire a PHP function within a plugin. The PHP function is supposed to fire using a custom jQuery action with ...
0
votes
0answers
30 views

Woocommece Remove Action not working at all - nothing in debug log

I'm trying to create a remove action for the woocommerce points and rewards plugin but I cannot get it to work. I haven't tried to remove an action that's like this before so any help would be ...
0
votes
1answer
179 views

How to change currency programmatically on creating order action?

A Payment Gateway I am using expects only Croatian currency so I am trying to update cart total and its currency by using a filter on placing order if the currency is Euro. I have successfully change ...
2
votes
1answer
37 views

Using wp_insert_post and post_update_meta but need to fire save_post afterward

I am using a calendar plugin. I have been using form data to create a new custom post type of calendar plugin and then update post meta custom fields for that calendar plugin. This works. However ...
0
votes
1answer
19 views

dynamic add_action according to child pages (for homepage control)

I'm using the plugin homepage control in many projects and really like what it does. I can create custom sections for my static homepage and can sort them in the customizer. In my recent client ...
2
votes
1answer
19 views

How to check if an action is already fired?

How to check if an action is already fired in a function for example: function foo() { // checking if the action 'wp' is fired if( !action_fired('wp') ) { trigger_error('invalid call'); ...