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
0answers
144 views

Woocommerce: Update SKU after add to cart button

Some products have the standard SKU (inventory) field from woocommerce (SKU1) and an extra SKU (sku2) custom field. I added a mandatory selection box: "With barcode", "without barcode", if the user ...
0
votes
0answers
131 views

Set global $wp_query/$post variable for dynamic page generation

This is a difficult one to describe, but I'll do my best... I'm trying to set up pages that can be shown based on a second (meta/ACF) slug, dependent on the language the user is using. Essentially, I ...
0
votes
0answers
47 views

How to override parent theme actions

Working on a child theme. On the parent theme functions.php there is a 'widgets_init' action where four sidebars are regsitered. I need to remove three of those sidebars. What is the propper way to ...
0
votes
0answers
19 views

Unable to remove action from parent theme

I have a problem with remove action from parent theme in my child theme. Parent theme code: add_action('custom_action_name', 'function_name', 10); function function_name() { //something } Child ...
1
vote
3answers
40 views

How do action and filter hooks understand where to look for the core function that we hooked our function to them

I want to know how does WordPress core files handle the relationship between module and core of the WordPress? We all know it uses add_action() and add_filter() to manipulate data according to our ...
0
votes
1answer
158 views

Change order of custom submenu link in WP Admin?

I've added a custom link to WP Admin under the Users menu, but trouble is I can't seem to get it to display above the default options. Is this possible? My code: // Add sub-menu option to users menu ...
0
votes
1answer
21 views

How to access deleted term inside delete_product_cat action

I want to run some code after a product category is deleted, in that function I want to access the name of the deleted category, and according to their docs I could do this: add_action('...
0
votes
0answers
20 views

Add_filter not return any output in custom plugin

I am using WordPress Boilerplate plugin structure to create a custom plugin.Add_action works but add_filter function not returning any output. Here is my code. includes/class-post-rating.php file ...
0
votes
1answer
32 views

Posts feed number of posts

Happy Holidays everyone! I hope you can help me with this 'little' problem I'm having :) I am using a child theme based on Elara which displays the posts feed in different formats on the front page ...
0
votes
1answer
80 views

How to check, if user commented before, on comment_post action?

I want check, if user commented post, in comment_post action. So i make this: function checkUserComment( $comment_ID ) { $comment = get_comment( $comment_ID ); $postID = $comment->...
0
votes
2answers
278 views

Remove actions/filters that are set with create_function()

This theme I was handed from another dev company is littered with add_action/filter( 'hook/filter', create_function( '', 'return blah('blah')' ); We will be moving this site to a server running php 7....
0
votes
1answer
46 views

add_action not calling back to function

I am working on a plugin, but add_action doesn't call the callback. The code is as follows: require plugin_dir_path( __FILE__ ) . 'includes/class-network.php'; $distro = new Classnetwork(); ...
0
votes
0answers
22 views

Add to edit edit user profile page, above the edit_user_profile hook

I want to add to the edit user page (for admins) but the action hook edit_user_profile shows up quite low in the page. Is there a way to get this up higher? I've been unlucky searching for this so ...
0
votes
0answers
14 views

in the post admin, is it possible to make the post title input disabled using php?

I am customising my product post type and auto generating the post title using add_action('acf/save_post'). See my php below for this... class Product { /** * product constructor method. ...
1
vote
0answers
29 views

How to properly modify WP Vary or any existing headers?

I have a site that currently have a some part of the headers like: Vary: Accept-Encoding, Cookie I want to modify it to be: Vary: Accept-Language I tried the suggestions here using this code ...
0
votes
0answers
48 views

Remove action hook from Class, understanding OOP

I am trying to remove an action that is within a class, of the parent theme. I made an example of the code I have, below. I am trying to remove the action in the child theme functions.php. I've tried ...
0
votes
1answer
26 views

How can I locate where the actions are defined? [duplicate]

Given the following code: <form> <h1> My form <h1> <input type="text" /> <?php do_action( 'woocommerce_checkout_after_customer_details' ); ?> </form> ...
-1
votes
1answer
234 views

Cannot modify header information - headers already sent

So I have a form on one page, which is submitting to admin-post.php, then there is a function in functions.php which is processing the form. It stores the input field data to database and then after ...
4
votes
1answer
702 views

How do I enqueue a script to run inside the Gutenberg editor?

I'm using the Gutenberg editor as a replacement for a whiteboard in a classroom. I'm able to make the classroom more interactive by having students work directly inside the Gutenberg editor. As a long-...
0
votes
0answers
181 views

Can run cron event manually with WP-CLI but not with any plugin, unsure if it's being scheduled

I have a cron event that I am able to manually run with wp cron event run --all When I go to my dashboard and go to WP-Crontrol OR Advanced Cron Manager, I can see my event listed and tell it to ...
0
votes
0answers
23 views

What is the recommended way to save errors / warnings / user messages from actions / filters for custom display in the frontend?

This is a very basic question and there are a lot of solutions to it - however what is the recommended (or at least a good) way? Problem statement: While processing a request to a WordPress project ...
3
votes
1answer
186 views

Restrict access to admin but allow admin_post hook

I'm using this hook to allow only admin roles access dashboard add_action( 'admin_init', function() { if ( defined('DOING_AJAX') && DOING_AJAX ) { return; } if ( !...
0
votes
1answer
27 views

Does anybody know what the $current_screen ->id for customizer.php is?

I searched high and low & tried a bunch of different things but I still wasn't able to add inline css to the customizer.php page. I usually employ page id $current_screen ->id === " " for ...
0
votes
0answers
10 views

On opening Edit New Post, insert something in editor [duplicate]

I would like to automatically insert a shortcode every time one opens the editor for creating a new post, for a particular post type. So that the editor is pre-populated. It shouldn't happen for ...
0
votes
3answers
2k views

Ajax call to php function doesn't work PHP code

I have a form like this: <form method="post" action="" id="BookingForm"> <label for="email">Email</label> <input type="text" name="email" id="emailId" value="" /> &...
-1
votes
2answers
87 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
70 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
17 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
119 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
36 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 ...
2
votes
0answers
42 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
45 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
413 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
71 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
70 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
104 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
516 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
146 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
38 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
108 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
576 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
363 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
62 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' ); ...
1
vote
0answers
334 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
166 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
1answer
41 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
54 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
2answers
47 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
89 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
1answer
40 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 ...