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
9 views

Ninja Forms: Front-End Forms, Post ID?

I have been scouring all day, trying multiple things to get the Post ID of the Create Post action within a Ninja Form and it doesn't seem to be possible. The reason I need to, is because the data that ...
  • 627
0 votes
0 answers
11 views

Reposition variation stock message

Due to some requirements, I had to make a change so the price for a variable product replace the price range. However, the stock status remains visible after the variations dropdown. Is there a way to ...
  • 113
0 votes
0 answers
19 views

Add text when displying attribute with a hook on single product page

I have books as products in woocommerce and I'm trying to show the order of the book in the series. It should look something like this: "The book 1 of Series" I've managed to add the link to ...
0 votes
1 answer
10 views

Hooks to trigger a callback when adding, removing, rearranging or updating a widget in the widget area

I am looking for hooks that fire when inside of Appearance -> Widgets: A widget gets added to a widget area A widget gets deleted from a widget area Widgets are being rearranged to new positions A ...
  • 143
4 votes
1 answer
64 views

delete_term is not working properly with add_action()

delete_term is not working, I'm trying to delete term and after I deleted it, it'll also delete the similar term from different a taxonomy based on their slugs here's my code of the delete_term, so in ...
0 votes
1 answer
32 views

How to sort custom sortable column by custom table value

I have a custom table with data in it that I am showing in a column. I would like to make this column sortable. Lets say that the custom table has three values for the sake of simplicity. row_id, ...
2 votes
2 answers
39 views

Theme's featured image option is not showing up

I'm new to WordPress development. I watched a video on how to add featured images. For some reason it's not working, and I can't really figure out why. The option for featured image is not showing at ...
  • 23
4 votes
1 answer
57 views

Is there any filter or action hook to remove layout classes from appearing in my templates?

With the new WordPress 6.1 core update, my site is now having a is-layout-flow class added to the layout. Normally this wouldn't be a huge issue. However, we are using the WP API to feed the content ...
  • 151
0 votes
1 answer
45 views

HELP: Code To Check Status And Write Debug Entry

I use a simple function to send out a 'heartbeat' to a website uptime monitoring service (Better Uptime): function my_better_uptime_heartbeat() { wp_remote_get( 'https://betteruptime.com/api/v1/...
0 votes
0 answers
32 views

How to change wp-admin and wp-login urls

I need to have a custom login url for a wordpress website that will use an headless theme to show a registration form. I've tried using the login_url filter but the result isn't really what I was ...
  • 1
1 vote
1 answer
41 views

Use add_action to run a script, but only on the post editor page

My JS script runs on every page, but I want it to run only on the post editor page. function sm_validate_title() { echo " <script> console.log('script working') ...
0 votes
1 answer
24 views

Hook automatic_updates_complete to autoupdate plugin

I'm trying to trigger some internal update class when WP is autoupdated. For manual update (when clicking on update), I found a way, it's pretty well documentated, I use the hook add_action( '...
  • 21
0 votes
1 answer
21 views

Can you call a filter hook by "add_action"?

I'd think you can't. But I come across this code in a plugin's file: add_action( 'render_block', array( $this, 'render_block' ), 5, 2 ); public function render_block( $block_content, $block ) { ..... ...
  • 131
1 vote
0 answers
30 views

My wp_update_nav_menu action is firing twice

i am trying to setup a wp_update_nav_menu action in a Plugin. Now I wonder why this is firing twice. I want to update all my pages with this hook in a headless wp implementation. And this double ...
0 votes
1 answer
117 views

Webhook: save_post action fires wp_remote_post twice

I am trying to implement a webhook in a plugin which should fire everytime a user saves a post. It works fine, but I recive two requests on frontend api. The first request has got a wrong slug. I ...
2 votes
0 answers
132 views

Is there a way to prevent wp_head from outputting self-closing tags?

I'm a beginner in WP development, so maybe I'm missing something obvious. Is there a way to prevent wp_head from outputting self-closing tags? Here are two example lines taken from my website: <...
  • 21
0 votes
0 answers
17 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
154 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
311 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 ...
  • 9,128
0 votes
0 answers
327 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
65 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
36 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
13 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
304 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
22 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
27 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
386 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 ...
  • 183
1 vote
0 answers
159 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
101 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
122 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
109 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( '...
  • 407
0 votes
1 answer
28 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
162 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
14 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
367 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, ...
  • 206
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
38 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
25 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
62 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
669 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 ...
  • 393
0 votes
1 answer
38 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
1 answer
62 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
22 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
170 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
170 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
169 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
48 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
322 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
2 3 4 5
29