Questions tagged [actions]

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

Filter by
Sorted by
Tagged with
1
vote
2answers
25 views

Get updated post meta on save_post action?

I'm trying to save post id and keyword (Yoast Focus Keyword) to a custom table when post is created or updated via save_post action. It saves everything fine on Publish (first-time) but when I update ...
0
votes
0answers
22 views

Fire action after enqueue script

I have a color switcher but its css files load before default css files.so, it doesn't work good.I want to fire it after enqueue script.after all css and js files on the website, I want to load my ...
0
votes
1answer
32 views

Remove an action created by a Gravity Forms add-on

I'm using Gravity Forms User Registration add-on and need to remove the action that include the activate page. In the add-on, the hook is called like this: add_action( 'wp', array( $this, '...
0
votes
1answer
31 views

How to pass a variable between filter/action functions?

In a function fired from filter wp_handle_upload_prefilter, how can I utilise a variable obtained from previously firing action edit_user_profile? My aim: on user-edit.php, when user uploads a file (...
1
vote
1answer
39 views

Is there a filter called 'network_admin_init'?

Is there a network equivalent to 'admin_init', or what do I have to do to add an action to network admin screens? I use 'admin_init' for an action on admin network screens, but the respective function ...
1
vote
0answers
11 views

How to hook a custom user function to a wordpress core ajax action?

I need to call a 3rd party API when a permalink edit happens for a post.I found once an edit happens, it calls an ajax function with the core wp post action 'sample-permalink'. How to hook my custom ...
0
votes
0answers
19 views

Add metabox if there is at least one post available

So I am building a WordPress Dashboard widget which will showcase all posts & pages where a Gutenberg Block is active. The below code does it's job and pulls in an array based on get_posts(). Here ...
0
votes
2answers
47 views

Delete data from database using row action

I have little problem how implement deleting data from database using row actions. I have my custom list which includes data from database table. function column_name( $item ) { $delete_nonce = ...
0
votes
2answers
19 views

Adding overlay search to wordpress using add action/filter

I want to add custom overlay search to my WordPress site using add action. Somehow, it is not triggering the javascripts to show the overlay html. However, it is working in a browser when I test ...
0
votes
1answer
20 views

Wordpress sent multiple requests on update

I have a problem with hooks being fired multiple times when I press update on a post (page in this example) I tried everything here: Unable to prevent function using save_post firing twice But since ...
1
vote
1answer
34 views

Code run fast on a cronjob but slow with a do_action or ajax call

I am creating several posts from a csv, when I execute the code using a cronjob the operation lasts about 7 minutes, but if I use the code directly in a template, or make a call to do_action or ...
0
votes
1answer
53 views

How to remove an action that is added inside a class

Here is the code in short that is coming from a plugin: class Post_Views_Counter_Columns { public function __construct() { add_action( 'wp', array( $this, 'admin_bar_maybe_add_style' ) ); ...
2
votes
0answers
29 views

What is the best filter where to use register_block_type?

I'm using register_block_type to register my blocks. I'm not sure what is the best hook to use, between init and enqueue_block_editor_assets. I suppose that enqueue_block_editor_assets it is loaded ...
0
votes
0answers
23 views

Run function after loading components into gutenberg editor sidebar

I would like to run a function after I load the meta box/components into the sidebar just in the gutenberg editor. I know I could do it with add_action('add_meta_boxes'), but the function I want to ...
0
votes
0answers
31 views

Debug: How to find out all functions hooked to an action

I reworded this question to show mine is a general question that is not totally depending on a 3rd theme/plugin. I have read this How to know what functions are hooked to an action/filter?. It seems ...
0
votes
0answers
23 views

Validate nonce with post ID in AJAX

I'm trying to create a nonce in an AJAX form where I can pass in a post ID. Then, validate it of course. I want to confirm that if the action is intended, but also the post ID so someone cannot just ...
0
votes
1answer
37 views

Is there a way to know when a page has been updated and do some action only once?

Have few pages in wordpress cms. Whenever any page is published or updated, there is need to do some action (basically call an API to update some data in another backend service). For publish, I am ...
0
votes
1answer
18 views

add_action taking an array with the 2nd argument?

I was going through some source code of Astra theme and found these lines in theme/astra/inc/class-astra-loop.php: class Astra_Loop { ..... public function __construct() { add_action(...
0
votes
1answer
15 views

style_loader_tag not changing stylesheet to preload

I am trying to change rel='stylesheet' to rel='preload' using style_loader_tag but it isn't doing something. Could anyone please tell me what is wrong with my code? add_filter( 'style_loader_tag', '...
0
votes
1answer
27 views

add element with add_action to posts from a specific category ID

I just try to add some content at the bottom of each posts from a specific category but the content is added in all posts. I use a hook in GeneratePress theme. I don't understand why it is not working....
0
votes
1answer
49 views

I need help using pre_get_comments to limit comments in the comments admin screen

I am trying to limit the comments in the comments admin screen to: Display all comments for the current user Display all the comments made on the current user's post if(!current_user_can('...
1
vote
1answer
34 views

How to redirect user after login to a specific page?

I have a page with mixed content in three different tabs. The first tab is open access to all but the content of the last two are for logged in users only so by sending the users to login with: <p&...
0
votes
2answers
45 views

How to check in functions.php if there is data in a WP_Query?

I have 2 different WP Query on the home page. I need to check $home_query condition in functions.php then I want to do something if $home_query returns null. I tried with pre_get_posts action I couldn'...
0
votes
0answers
14 views

How to show error message in admin panel using WordPress?

I'm using WordPress and I want to add validation for the save_meta_data function and if the request isn't validated admin panel should show the error message. my code is here: public function ...
0
votes
0answers
16 views

do_action in API call

I have a woocommerce plugin and it provides an API url ?wc-api=myplugin. The plugin adds a new email also. function add_newstatus_woocommerce_email( $email_classes ) { require( 'emails/class-...
1
vote
1answer
60 views

Can the wp_filter object hold multiple values with the same key

I'm trying to understand the internals of the $wp_filter object and I'm looking at the code posted by Fuxia in this question How to know what functions are hooked to an action/filter? function ...
0
votes
0answers
32 views

Adding link options in insert/edit link dialog window

Good afternoon! I am looking for a way to insert a text box inside this insert/edit link dialog window. Due to googles recent changes for rel/nofollow links, we would like to insert an option to add a ...
1
vote
0answers
51 views

Gutenberg - Dispatch action or setAttributes() on Post Save/Update action instead of onChange listener

I have a requirement to add up to 8 user selected custom colors to the list of default options when using the Colour Palette. I have registered a meta that saves custom colours. Problem: I want to ...
0
votes
0answers
19 views

Add Tag to post after publishing

I want to add a specific tag to posts being published, I tried the following code and searched for answers here but it doesn't work. Does anyone have an idea why? function tag_to_published_post( $...
0
votes
0answers
40 views

Action Scheduler: Scheduling actions via loop, only the first action successfully executes the function

Anyone use the Action Scheduler API? I am essentially looping and generating scheduled actions. That is all fine and dandy. The first action scheduled is called and the function is executed. However, ...
0
votes
1answer
79 views

Dequeue styles with query doesn't work

In my theme there is the following code (that is printing some inline css on the head of my site) final class Design_Scheme { /** * Design_Scheme constructor. */ private function __construct() { ...
0
votes
1answer
29 views

remove an action hook function on a plugin from a theme

first I did my homework by checking the answer on this question and this question, both didn't work. after long debuging the function I want to remove is protected in 2 nested classes, and follows ...
0
votes
1answer
14 views

How can I specify the post status of an untrashed post?

By default Wordpress assigns the draft status to a post that has been untrashed. I would like to assign the pending status to posts that are untrashed. This seems to be possible with ...
0
votes
0answers
16 views

How can Use custom input field in functions.php page?

I have if clause to add action in functions.php page. But I want to give condition value from dashboard as a custom input instead of defining it functions.php. When I am trying 'echo get_field('...
0
votes
0answers
27 views

user_register is having empty first name and last name

I am using the wordpress : User registration plugin. When users register using the form it adds the first name as well. but while using the add_action user_register the first name is always empty. ...
0
votes
1answer
41 views

update_option_{$option} not working (do function after options are saved)

Below is my code for a simple plugin settings page. It works and saves an option ("EN", "CZ"). However, what I intend to do is run a function after the options get saved (see at ...
0
votes
1answer
25 views

How can I collect and output all attributes of all executed ShortCodes?

I would like to collect all attributes of the shortcodes that are stored in a page in the ShortCodes and then output them all. I do these in a Plugin. 1.) Set a global Variable in init.php ==> $...
0
votes
0answers
15 views

Update a custom role with new capabilities

I have created a custom user role for a site where the role can do almost anything an administrator can do minus a few capabilities like: -Update, Delete, Upload plugins -Change, Delete, Upload Themes,...
0
votes
0answers
20 views

How can I stop ActionScheduler recurring task running after 5 runs?

I am using the ActionScheduler library from WooCommerce as_schedule_recurring_action() function, and am trying to find a way to stop recurring tasks running after 5 runs. I have not seen any parameter ...
0
votes
1answer
26 views

remove_action: how to access to a method in an child class?

I've this in my main plugin file: $main_admin_class = new MainAdminClass(); $main_admin_class->init(); MainAdminClass has this code: class MainAdminClass { public function init() { $...
0
votes
1answer
25 views

I would like to send a notification email (Asana) whenever something is published (posts, pages, custom post types) [duplicate]

The code below works perfectly When I create a new post, an email is sent out to the email included in the function. I would like to know how I can send an email when anything is published on the ...
-1
votes
1answer
23 views

Remove action of an external plugin after checking if custom post meta is set

Edit:The problem were 2 folds - somehow the order list I found before indicated wp_head was before wp_enqueue_scripts but that is not the case. Found another more updated one and it is actually right ...
0
votes
1answer
24 views

default post thumbnail and category if there is no thumbnail and category

I want to do following... 1 - Publish the new post, 2 - Check if this new post has a featured image, 3 - If it has not a featured image, define its category and save the specific prepared image as the ...
1
vote
1answer
30 views

Custom HTML in specific category single page and its descendant categories

I am trying to insert a "style" in single page of a category and its child categories. .relatednews{display:none}. I inserted the following code in functions.php of Child Theme, but it didn'...
0
votes
0answers
30 views

How to redirect a unique link based on login status

I have webstore on woocommerce, and on one of my wordpress pages (that page is not woocommerce page, but just wordpress and it is edited by Colibri free theme) I have download links for some products. ...
0
votes
1answer
16 views

Gravity Forms parameters return 1

I'm not sure what's causing gravity forms $entry and $form parameters to return 1. Here is my class. namespace GrvityFormsIntegration\DataTools; ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' ); ...
3
votes
2answers
236 views

How to check if which hook triggered the call to a function?

I have a situation where I have a function hooked to more than one custom hooks. How to check in the callback function which custom hook triggered the call? Or the question in code will be add_action('...
0
votes
1answer
16 views

Nested "do" and "add" Actions is possible?

I'm wondering Questions were asked about more than one "add_action" and filter nested before and it was deemed possible. Are nested cross actions added? Eg. add_action('init', function(){ ...
5
votes
1answer
238 views

Do WordPress' cron's clean up expired transients?

WordPress has a cron named "delete_expired_transients" as seen in the image below. In this way, does it clean expired transients daily? Or is it just giving us action? Should we clean it ...
2
votes
2answers
175 views

Hooking new functions to actions + passing parameters

I am trying to understand some fundamentals of php with regards to adding new functions to actions. I found a tutorial where he adds a new function to the save_post action… add_action('save_post', '...

1
2 3 4 5
28