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
1answer
23 views

WordPress redirect redirecting too many times or not at all

I am new to WordPress. I am trying to simply redirect users to a login page if they go to the account page without being logged in. I first tried adding this code to the functions.php code: add_action(...
1
vote
1answer
102 views
+100

Adding rewrite rule dynamically

I'm trying to dynamically add a rewrite rule that allows one to access any page under an alternate permalink structure of my choosing. So for example, if the alternate permalink structure includes the ...
0
votes
1answer
27 views

Action / Hook when a new plugin is added

Is there an action hook when a new plugin is installed? I want to hook into the moment when a new plugin was put into the /wp-content/plugins folder. So really just adding the plugin (either via ...
0
votes
2answers
34 views

Can we change the hook firing sequence?

In admin, I need to fire the save_post action before firing the transition_post_status hook. But according to this, the transition_post_status fires first before the post is saved. How can I reverse ...
0
votes
2answers
31 views

changing genesis_before_while in new theme framework

I am moving a site from a Genesis theme to Colorlib theme. The genesis theme includes add_action( 'genesis_before_while', 'custom function' ); in a custom archive page, which loads restricted content ...
2
votes
1answer
157 views

Define a function outside a class and call the function using action or filter hook

Hi Currently i am developing a sub plugin for my own main plugin. Please see the main plugin code below <?php class MyClass { function __construct() { function test1() { ...
0
votes
0answers
23 views

apply_filters() and call_user_func() to define and call a function outside a class

Hi Please see the following code of my class class MyClass { function __construct() { $this->autoload_function(); } function autoload_function(){ $my_array=...
0
votes
0answers
23 views

Trying to update repeater field (ACF) dynamically with data from Contact Forms 7

I'm trying to feed a repeater field with the values submitted via a registration form (I'm using Contact Forms 7). When debugging the array of values passed to the "add_row" function, ...
0
votes
0answers
37 views

Is it possible to stop adjust_download_permissions from scheduling?

I've noticed with quite a few stores I manage that the actionscheduler_actions and actionscheduler_log are huge. After doing some research, it seemed to be the adjust_download_permissions job ...
0
votes
0answers
11 views

Wordpress Post Block Element not properly parsed with the_content filter

I made a small script which echoes the content of all Wordpress Posts on post_updated, deleted_post and trashed_post actions. add_action('post_updated', 'echoAllPosts'); add_action('deleted_post', '...
0
votes
1answer
20 views

current_user_can comma list vs OR (||) list

Can any help with this? I like the comma separated version because it's smaller to write and easy on the eyes, lol, but I can't make it work. //** WORKING - Works on the Checkout page add_action( '...
0
votes
1answer
22 views

Inject div from plugin into DOM, no matter what theme is installed

I write a small cookie consent plugin for a Multisite network installation. So, when the plugin will be finished, it will be available to all instances of a multisite installation. To make it work, I ...
0
votes
0answers
20 views

Rewrite the search page to use an appended slug + parameter

I have two URLs that handle search ~/search/ = main search page ~/?s= = results page What I want: to have one search page where the search parameter for the results page appends to the search page ...
0
votes
0answers
14 views

Session management issues with WordPRess 404 Error page

I have tried to integrate wordpress into my existing website as the documentation archive using the existing login session. I have installed wordpress under /wp of the root app. In my main app, I set ...
0
votes
1answer
26 views

Call to undefined function is_home() or any conditional tags

Currently I am coding in my own custom plugin. For some reason I can't use conditional tags inside my function. For example function check_home() { if(is_home()) { $my_val=1; } else { ...
0
votes
1answer
18 views

Override a function defined in wp-includes/comment-template.php

I need to override the function get_cancel_comment_reply_link or cancel_comment_reply_link that are defined in wp-includes/comment-template.php These functions are not listed in pluggable.php. How ...
0
votes
0answers
36 views

Using `set_transient()` when saving a custom post type

I've got multiple custom post types registered via a plugin and one of them is used as a precursor for multiple other queries. In an attempt to reduce queries throughout the site, I've attempted to ...
0
votes
1answer
26 views

How to call do_action() to pass arguments to hooked functions that take different number of args?

Here is a simple example to explain my question. 3 functions are hooked into the myaction. Each take a different number of args and the args can be a number of an array of numbers. So args can also be ...
0
votes
0answers
24 views

Using publish_{custom-post-type} hook for custom post type to update meta doesn't work

I am using publish_{custom-post-type} hook to update meta of the post that has just been published. The post-type is jobboard-post-jobs. Why isn't it working? add_action('publish_jobboard-post-jobs', '...
2
votes
2answers
36 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
26 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
35 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
34 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
57 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
12 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
21 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
148 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
35 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
45 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
45 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
64 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
33 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
31 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
62 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
26 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
39 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
24 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
16 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
43 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
88 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
46 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
68 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
19 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
43 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
73 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
76 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
1answer
152 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
28 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
72 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
86 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() { ...

1
2 3 4 5
28