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

Hook in the loop after the first post

I am trying to hook content in my wordpress loop. I'd like to insert a div after the first post. I've found this code, that works pretty well except that it repeats the hook every 4 posts : add_action(...
  • 1
0 votes
1 answer
45 views

WP_Query - How to get all posts of specific days of week by custom field date?

I have a filter on frontend with days of weeks, and I need show only posts that are published on especific day (or days). The date are on custom field day_of_event (the filter is based on this field, ...
2 votes
2 answers
137 views

Hook for inserting?

I'm using a plugin that doesn't provide many hooks for its actions. I would like to be able to hook in when the plugin adds a row to a plugin-specific table, and update some other data elsewhere. (For ...
  • 8,853
0 votes
0 answers
36 views

Elementor posts custom query based on tag [closed]

How can I filter the Elementor Posts widget with a custom php query that returns posts with a specific tag attached? I want to do something similar to this: function my_query_by_post_types( $query ) { ...
0 votes
2 answers
50 views

Is it possible to add the_content filter upon login?

I've added a wp_login action and it's getting executed. Then within that function, I'm adding a filter to the_content so that a script gets inserted upon certain conditions but it's not getting ...
  • 1
0 votes
0 answers
19 views

Sharing variables in both actions wp_footer and wp_ajax

I have some code in my functions.php that, under a specific time condition, showes a popup that notices about some database update routine. What is happening here, is that when this condition happens, ...
0 votes
0 answers
9 views

Change image data durgin upload

I try to change image filename and image meta during upload to media library. I have a problem with create unique filename hence, a bad slug is generated. Also, during upload, file uploaded by this ...
  • 1
0 votes
0 answers
44 views

Display custom product option in admin order details

I'm trying to display the custom product option in admin order panel. I was able to pass all the data until the order is completed, but in the admin panel the data is returned is empty array. I share ...
0 votes
1 answer
21 views

Restrict editing of post type to list stored in user meta

What is the right action to invoke before a custom post type is getting edited in dashboard and contains the argument the post id? The url /wp-admin/post.php?post=282&action=edit&classic-...
  • 824
0 votes
1 answer
25 views

Add new users to "add new user" page on admin's dashboard

I understand there's a lot of similar questions, but all of them show how to update the wp_usermeta table in the database, whereas I want to use wp_update_user() to update a particular field (nickname ...
0 votes
2 answers
127 views

How to stop execution of a function via add_action hook?

I have the following functions: function test($post_id){ do_action('test_action',$post_id); echo $post_id; } add_action('test_action',function($post_id){ if ( $post_id == 2 ) //Stop test function ...
  • 83
1 vote
0 answers
108 views

add_action and do_action: multiple calls to same callback?

I have a setup similar to this: function get_type_data($val) { // Get the data from the DB where the ID is $val and return it. } add_action('my_hook', array($this, 'get_type_data'), 10, 1); I ...
0 votes
1 answer
43 views

Ajax callback not work

My files is : synergyservice.php register_activation_hook( __FILE__, array( 'Synergy', 'plugin_activation' ) ); register_deactivation_hook( __FILE__, array( 'Synergy', 'plugin_deactivation' ) ); if ( ...
0 votes
0 answers
67 views

admin-ajax.php calls fail if referrer is sent with 500

calling admin-ajax.php via jquery ajax calls were failing from my site but postman calls to the same url were successfull. After some looking at headers it seems that the referer being set is the ...
0 votes
1 answer
51 views

How to pass multiple parameter in add_action()

I have below code. add_action( 'admin_init', [$this, 'settings_page_registration'] ); I would like to use enqueue_assets function name inside add_action(). Should I use like below ? add_action( '...
  • 397
0 votes
1 answer
26 views

Prevent posts with certain post_meta to be edited

So I am looking at adding some custom post_meta to posts and I want those posts to not be editable, which will be some content that I am pulling in. Here is what I have: I have solved the issues when ...
  • 3
2 votes
1 answer
115 views

Find variables available at a given hook

I'm hoping for a simple way to tell/find/echo what the available arguments are available for use at a given hook. For example — function example_function($something){ //do stuff with $something ...
  • 123
0 votes
0 answers
12 views

Displaying page content from plugin, inside exising empty WP page

Old php developer here, very.. very new to WP, so be kind. I am building my first WP Plugin. I have this in the plugin central file (the one that is /plugins/my_plugin/my_plugin.php): // Setup the ...
0 votes
1 answer
112 views

Update media library image shown in "attachment details" when using wp_insert_attachment to add item to the media library

I'm using the function wp_insert_attachment() to run on a form submission from GravityForms, take a file uploaded in the form, and add it to the WordPress Media Library. Code in functions.php below, ...
  • 176
0 votes
0 answers
20 views

Replace Data In Post & Update Meta Field Post Is Saved

I'm a bit lost & I'm wondering if someone can help. I have a post that is being generated from a podcast feed. That feed contains an audio player using the <audio> tag. I wanted to remove ...
0 votes
1 answer
34 views

What is @Action in Wordpress?

I have found this code snippet on a plugin. /** * @Action(name="workforce_content_loop_before", priority=10) */ public static function show_breadcrumb() { echo do_shortcode( '[...
0 votes
1 answer
21 views

How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?

I created a custom plugin and I need to schedule add_action using Crontrol Plugin, the Setup class is from different php class. But the schedule action cant read the Crontrol even if I execute ...
1 vote
1 answer
59 views

Should action callbacks start with a verb?

class Singleton { public function __construct() { // Case #1 add_action( 'woocommerce_before_shop_loop_item', [ $this, 'open_product_wrapper' ], 10 ); add_action( '...
0 votes
1 answer
176 views

Wordpress action - Pass arguments into action in an AJAX call?

My theme uses a custom action which expects two arguments. I am trying to call the function in an AJAX call but because I am not passing those arguments I end up getting a 500 error. The action is ...
  • 383
0 votes
0 answers
22 views

How to use wp_enqueue_script properly?

I'm trying to load mine scripts, but it doesn't work properly. function theme_enqueue_assets() { wp_enqueue_script('load_more', get_stylesheet_directory_uri() . '/assets/js/load_more.js', array('...
0 votes
1 answer
36 views

How to catch wordpress post ID when it's published

I am trying to either automatically a forum section when a post is published - like a discussion page. Normally, I wanted to make the users create the topic but I realized a forum category with many ...
0 votes
0 answers
23 views

How do I add an action using namespaces, and file separation? [duplicate]

I'm working on a plugin, and I'm trying to get to grips with namespaces and how they work with actions. In a separate file, I have a single function with a namespace declared at the top: namespace ...
  • 206
0 votes
0 answers
42 views

Hook from plugin doesn't fire up from external PHP script

I have this habit of installing a plugin with all my custom hooks, instead of writing a functions.php file with the same PHP code in it. That way I get the same functionality without the need of ...
  • 123
0 votes
1 answer
47 views

Set Taxonomy based on post status

I am setting a taxonomy based on the post_status. It works as needed except I want to allow the taxonomy to be overridden if a particular taxonomy is selected. Here is the code function ...
  • 95
1 vote
0 answers
18 views

Plugin with action 'save_post' needs to press publish twice on order to publish

I have an old plugin, which used to work fine (years ago). Now I have to press publish twice to publich the post. The problem is in the blocks below. The used variables are declared above the code ...
  • 11
0 votes
1 answer
29 views

How to find where an action is triggered? [closed]

As far as I understand about the action hook, add_action is used to add callback functions to an exsiting action hook, which means, to make lines like add_action('some_action_hook',function(){ // some ...
  • 131
0 votes
1 answer
17 views

What do I put in the form action attr on top of form wordpress

I created an html form, but have no clue, what I must put in the <form action = on top of the form. Does the user info go to the database, or to a file in wordpress. I am not sure what to put there....
0 votes
0 answers
99 views

Prevent other hooks from firing after wp_update_post() outside of editor

I'm working on a plugin that batch updates post content using a call to wp_update_post(). This all happens outside the editor window, in a batch processing script. My problem is that ACF is firing ...
0 votes
0 answers
107 views

How to do admin ajax request in a plugin for rest api

This must be something very simple, but I cannot figure it out. I'm working on a plugin, that extends a theme's functionality to rest api. Theme has an ajax action function that updates user profile. ...
0 votes
1 answer
32 views

Hook add_attachment error

I am trying to optimize my images when uploading to website. I trying to write plugin, that will use hook 'add_attachment' and after attachment uploaded do image converting. add_action( '...
  • 21
0 votes
1 answer
117 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
1 answer
252 views

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 ...
  • 21
0 votes
1 answer
76 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 ...
  • 141
0 votes
2 answers
69 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
2 answers
34 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
1 answer
187 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
0 answers
25 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
0 answers
127 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, ...
  • 738
0 votes
0 answers
14 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
1 answer
28 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
0 answers
29 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 ...
  • 101
0 votes
0 answers
21 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
1 answer
77 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
1 answer
76 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 ...
  • 87
0 votes
0 answers
90 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 ...
  • 1,876

1
2 3 4 5
29