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

learn more… | top users | synonyms (2)

0
votes
1answer
575 views

Action hook “wp_insert_post” works but not for last imported post

I want to run a custom function whenever posts are imported to my custom post type. I am currently running this code - function on_post_import($post){ global $wpdb; $results = ...
1
vote
1answer
293 views

Restrict post edit/delete based on user ID and custom field

I've been able to prevent deletion and editing of posts based on user ID and page ID however, I need to restrict access to editing and deleting based on a custom field. Not sure how to go about doing ...
0
votes
2answers
1k views

Deregister scripts on unnecessary pages using remove_action

To all would-be close-voters: This question is not a duplicate, because I need to remove all scripts added by plugin using remove_action. In Very stubborn wp_register_script / add_action vs ...
0
votes
0answers
8 views

Action wp_footer with priority 1 is after wp_print_footer_scripts

In my Wordpress 4.1 instance I found a strange thing. The wp_footer action print_script with priority 1 is executed after wp_print_footer_scripts which has priority 20. add_action( 'wp_footer', ...
-1
votes
0answers
9 views

Plugin hook that only fires when a new post is published? [duplicate]

I wrote a plugin for my site which posts an update on my forum whenever a new post is published. I'm using the "publish_post" and "publish_future_post" actions. The problem is, these actions also ...
1
vote
1answer
431 views

Using add_filter() in Widgets

Just have a query reference the add_filter() function. Can you use this function inside a WordPress widget class. Example I have a widget with dynamic created code that I want to pass to another ...
0
votes
0answers
15 views

Object oriented programming, add_action in constructor not firing

I am trying to write a class that adds an action to the save_post hook, but the post_updated function never gets called. I tried some variations, but it never gets called. Am I doing something wrong? ...
1
vote
1answer
340 views

Implement Hooks Using Array

I'm trying to implement some hooks into a theme, but rather than write out every hook with repetitive code I was wondering if I could use and array to declare the hooks instead. E.g. ordinarily i'd ...
3
votes
2answers
318 views

How to modify wp_ajax function?

I want to modify wp_ajax_find_posts function. It receives search string from find-posts form and delivers search results by ajax. Part of the function looks like this: function wp_ajax_find_posts() { ...
2
votes
2answers
1k views

How to use filter hook 'post_updated_messages' in coherence with action hook 'save_post'

I am trying to send out e-mail, SMS and IM notifications to group members of this WordPress website, whenever a WordPress page in their user group has been published/updated. I figured using the ...
0
votes
2answers
2k views

How to append new form elements in “Add New” form of Users in Wordpress admin panel?

I'm developing a WordPress plugin and I want to append some extra form fields in add new form of Users section inside admin panel without editing core files. Can somebody help me in achieving this.
0
votes
1answer
52 views

Fatal error: Call to undefined function add_action() - an untouched problem

The question was asked many times in many ways, but unfortunately is not covered well in most of the answers. I'm having the same issue doing things using include-files. In my TwentyFourteen child ...
1
vote
0answers
34 views

Add custom buttons with custom actions in Edit Post screen in WordPress?

I am creating something for a client and I have a Class that I created with a Custom Post Type called 'PuSH Feeds' and when the user adds a new post and publishes it they can then click on one of two ...
0
votes
1answer
13 views

add hook restricted only to either plugins or themes?

I'm writing a plugin and I want to create two hooks like the following: add_action( 'myplugin/ready_for_theme', array( __CLASS__, 'myfunction_for_themes' ) ); add_action( ...
1
vote
1answer
509 views

WP Login forms action URLs displayed as pretty URLs in browser (ex with Restore Password)

I would like to use the WP native login/register/restore password/.. functionality, but display pretty URLs instead of wp-login.php I've been looking at the core code and noticed that most login ...
0
votes
1answer
416 views

get_term and get_term_by returning null or false eventhough the term exists

I am trying to use the action hook delete_term, delete_$taxonomy, among other hooks that delete a term but they are presenting the same issue. For example: 1234 is an existing term in the favorite ...
0
votes
1answer
48 views

Should I use add_action('publish_post or add_filter('publish_post?

I am trying to trigger an extra function as soon as a certain custom post type is published function insert_table_products($post_id, $post) { if ($post->post_type == 'custom-products') { ...
0
votes
0answers
13 views

add_action - $function_to_add first argument defaults overwritten

I have an issue with the following code, $function_to_add first argument defaults are overwritten with an empty string "" and it cause an error: Warning: join(): Invalid arguments passed The second ...
3
votes
1answer
718 views

Check if post is being published for the first time, or is an already published post being updated

I am building an add-on to an events module that checks for availability, since there wasn't a function for that in that module. Now that I have built the logic, there are three emails I will need to ...
0
votes
1answer
299 views

Redirect back to origin page after using get_delete_post_link()

I need to implement frontend and backend redirection after delete specific post using get_delete_post_link(). Which hook i can use? Any advice would be appreciated. Something similar to : <?php ...
0
votes
1answer
485 views

Insert new user with form submit 'init' hook

I'm posting a form to insert a new user and hooking my function to 'init'. This code is in my mu-plugins folder. The user gets inserted fine, but the page is not loaded after wards. My form action ...
0
votes
0answers
19 views

Remove action added from class

This has been asked before and I know how to do this but im having trouble removing a specific action added by the easy columns plugin. The action is added similar to below: class EasyColumns { ...
0
votes
1answer
28 views

WordPress HTML Helper

I've played recently with WordPress Hooks and I've noticed that in order to create layouts based on the hooks the main practice is to use html in functions and combine them with logic. I've searched ...
1
vote
1answer
29 views

Problem:Save Several Duplicate posts in The Database and then Error nesting level of '100' reached

I have a function to insert a single post in the database. But when I run the function, duplicate posts (40) are added to the database and then an error is displayed. Fatal error: Maximum ...
0
votes
3answers
670 views

How do I add some javascript validation to the admin interface form's onsubmit?

I have a plugin that adds meta boxes to the admin interface and I need to do some validation when the user presses the "update" button before the form is submitted. Is there a WordPress action or ...
0
votes
1answer
2k views

Disable WooCommerce action

I'm customizing a WooCommerce theme and am going to be moving the title. There is an action in content-single-product.php called: do_action( 'woocommerce_single_product_summary' ); in the ...
0
votes
1answer
37 views

add_action in the loop hooks

I have the following structure: add_action('my_content', 'standard_loop'); function standard_loop() { if (have_posts()) : while (have_posts()) : the_post(); ...
7
votes
4answers
2k views

Remove an action from an external Class

I'm trying to do something similar to this question here: remove_action or remove_filter with external classes? I'm trying to remove the <!-- This site is optimized with the Yoast WordPress ...
0
votes
1answer
357 views

Create action running on trashed_post hook to modify post_meta value

I have a custom post type that always do math operation to its post_meta and other custom post type post_meta. For example: post-type 1 = cpt_product_order post-type 1 post_meta = ...
0
votes
0answers
13 views

Problem with wp_login_form()

I'm using wp_login_form(); to display the login form in the front-end. And added after that do_action('login_form'); which should display capacha verification from a plugin. The problem is that the ...
0
votes
1answer
22 views

Remove action working on functions.php but not in a plugin. Why?

I am trying to remove an action from Woothemes' Sensei plugin. If I do on the functions.php: global $woothemes_sensei; remove_action('sensei_lesson_video', array($woothemes_sensei->frontend, ...
0
votes
1answer
499 views

wp_trash_post action hook with custom post type

When a 'contact' cpt post is trashed, i need a metakey from another cpt 'act' to be deleted, i have been searching all over which hook i should use but unfortunatly the codex action reference page is ...
0
votes
2answers
416 views

What is the action hook that deletes a taxonomy term from the backend? And how to retireve the term id before deleting it?

I need to delete some postmeta when deleting taxonomy terms from the backend. Before deleting the term, I need to retrieve the postmeta's meka_key and the term id that is going to be deleted. Use the ...
0
votes
1answer
28 views

How to create shortcode for auto login after registration

I've a code for auto-login after registration which is: function auto_login_new_user( $user_id ) { wp_set_current_user($user_id); wp_set_auth_cookie($user_id); $request = ...
5
votes
1answer
35 views

Does the event 'wp_version_check' even exist? What is it doing?

In version 4.1 of /wp-includes/update.php around line 674, there's this line: add_action('wp_version_check', 'wp_version_check'); I searched through all the wordpress core files for a ...
0
votes
1answer
22 views

Which action gets triggered when i save settings?

I want to write to a file but i need to write/update this file every time user updates settings.Is there any action that gets fired every time user updates settings ? Edit: I have a new menu page and ...
0
votes
0answers
23 views

How to call plugin function everytime

This is probably a very basic and simple matter, but what is the command to call a function in my plugin every time the page is loaded? I think it is something like add_action() or do_action(). ...
0
votes
0answers
13 views

Get variable value outside action hook [duplicate]

I'm trying to get current screen within wp-admin for some conditional functions to run based on screeen name as follow : global $this_screen; function wporg_current_screen_example( $current_screen ) ...
0
votes
0answers
4 views

Custom action in meta box

I have added a meta box to the order info page on WooCommerce but can grasp how I can run an action on the order? I have created the box using: /** * Part to add a meta box to the order info page ...
0
votes
1answer
23 views

How wordpress plugin hooks works? [duplicate]

I am new to wordpress development. I am familiar with joomla's ins-and-out working mechanish, now i want to contribute or say learn wordpress. I found that every thing in wordpress is done through ...
0
votes
1answer
31 views

add_action and do_action

I am trying to hook a function to wp_head that adds some meta tags, but I does not work correctly. Here is my code: add_action( 'wp_head', 'add_meta_tags' , 2, 1 ); ...
2
votes
1answer
914 views

How can I hook into creating a new post and execute wp_die(), before the post is inserted into the database?

Info about wp_die from codex: Kill WordPress execution and display HTML message with error message. A call to this function complements the die() PHP function. The difference is that HTML will be ...
0
votes
1answer
17 views

Other than save_post any other actions on add / edit post screen?

When the add post or edit post screens load, is there an action other than save_post which I can hook on to? I need to make an API request before a user starts adding / editing posts. Basically when ...
1
vote
0answers
29 views

Theme elements not translating

Ive got a theme that is set-up for translating but didn't come with any translations. I used poedit to automatically detect the strings, and subsequently translated it in full. However certain ...
0
votes
1answer
23 views

action future_post returns wrong date

Hi I am using a future_post hook to capture when a scheduled post is updated like so : add_action('future_post', 'on_post_scheduled'); Then I want to send the new post date to a database, however ...
1
vote
0answers
65 views

Having an add_action( 'user_new_form',)

I am using the following action; add_action( 'user_new_form', 'epx_add_user_form_to_admin_area',489); function epx_add_user_form_to_admin_area($current){ $current .= 'this is a test'; echo ...
0
votes
0answers
13 views

Trigger needed when meta data is updated

I need to update a MySQL table (not any of the WP/Woo tables) when a products meta_key "_stock" is modified. The trigger needs to fire on all updates: shop sales, a CSV merge or edits by admin in the ...
9
votes
5answers
8k views

add_action reference a class

Is it possible to reference a class instead of a function in 'add_action'? Can't seem to figure it out. Here is just a basic example of the function in question. add_action( 'admin_init', 'MyClass' ...
0
votes
2answers
40 views

Trying to write a function in an external php file to manage admin menu visibility

I am loading my php file by putting this into my theme's functions.php: require get_stylesheet_directory() . '/inc/manage-menus.php'; alter_menu('my-user', 'plugins.php', false); The code in ...
0
votes
1answer
25 views

How To Get User Data in Callback Function for pre_user_nicename?

Whenever I update a user profile in the dashboard, the user nice-name gets changed in the database: Every time, a "-2" is added. I tried to reset the nicename (based loosely on this thread) by ...