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

Questions tagged [actions]

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

0
votes
1answer
14 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
7 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
12 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
10 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
22 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
16 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> ...
0
votes
0answers
14 views

Wordpress template_redirect Not working as requested

I found this code to redirect a whole category to a new domain add_action('template_redirect', 'post_redirect_by_custom_filters'); function post_redirect_by_custom_filters() { global $...
-1
votes
1answer
30 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
75 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
20 views

Having trouble using wp_update_post

I am trying to create an action that will place the contents of a meta tag into the excerpt field, but I can't seem to get it right. The action is the publish event of a frontend submit plugin. When ...
0
votes
0answers
17 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
20 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
25 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
22 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
13 views

Remove action from plugin in another not working

I have 2 plugins with same structure. Let say plugin A and plugin B. They are generated with WORDPRESS PLUGIN BOILERPLATE GENERATOR (https://wppb.me/). I have some php (and ajax) methods in plugin A, ...
0
votes
0answers
32 views

Remove woocommerce actions for frontpage

basically i want to remove the default single product actions that woocommerce uses but only on the front page. To attempt this I first just removed the actions like so: // woocommerce hooks for ...
0
votes
0answers
9 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
0answers
23 views

Cannot apply filters from inside a function in wooCommerce for ajax posted data

My Ajax data is handled by the function my_currencySwitcher and I'm storing the ajax value in a global variable $postedValue and I'm applying filters and once in the filter I'm trying to assign the $...
0
votes
3answers
89 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
45 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
30 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
15 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
22 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
16 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
24 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
33 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
81 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
50 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
16 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
12 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
88 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
30 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
23 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
80 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
47 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
26 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
60 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
41 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
18 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 ...
0
votes
1answer
23 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
24 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
12 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
26 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
21 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
46 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
30 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
82 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
22 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: ...