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

learn more… | top users | synonyms (2)

0
votes
1answer
271 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 ...
1
vote
1answer
36 views

How to select a page within admin?

How does one apply an action to one particular page within admin? I've added a bunch of wysiwyg editors to one page ("Home") and now I don't need the main editor. But the function below - of course - ...
0
votes
1answer
178 views

template_redirect action only firing if logged in

add_action('template_redirect', 'add_header_redirect', 0, 0); function add_header_redirect(){ if( is_page(array(8, 'testimonials', 'Testimonials')) ){ $default_testimonial = get_permalink( ...
0
votes
1answer
187 views

add_action() in switch statement

I'm using the approach of having all of my single-views in one loop-single.php and thus have a simple switch statement that will render each single-view based on the post type: ...
0
votes
1answer
282 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
1answer
830 views

How to only hook on Single.php after content?

I am currently hooking on the_content() but that goes through the Wordpress loop too. How can I only hook on the Single.php page? Also, is there a way to only look on the first X posts in the ...
3
votes
1answer
477 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
203 views

OOP Plugin: Where should I place the action hooks in the class?

Where in my admin class should I place the action hooks for adding css, scripts and the add menu page? In the __construct? Or should they be placed in a method?
0
votes
1answer
115 views

delay function on publish?

I have this function where I call a custom function through the add_action hook: add_action('publish_post', 'custom_function'); ... now it works perfectly, but the I want the custom_function to be ...
1
vote
2answers
94 views

Too many actions/filters!

New to wordpress here. The concept of actions/filters in and of itself is not too difficult to grasp. What I am overwhelmed by is the HUGE amount of actions and filters available. When I am looking at ...
4
votes
3answers
1k views

How can I find out what functions are assigned to actions?

Is there any way to know what functions are added to actions on a certain page in WordPress?
3
votes
2answers
282 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() { ...
4
votes
2answers
8k views

When to use add_action('init') vs add_action('wp_enqueue_scripts')

In my theme's functions.php, I'm calling an add_action in order to gain a measure of control on where jquery is loaded (in the footer along with my theme's other scripts). The problem I'm having is ...
3
votes
3answers
707 views

How can I remove the WP menu from the admin bar?

I never use the WP menu (the logo and its child items) except when I click it accidentally. And it is wasting my time when I navigate per keyboard. Plus, the support page is not our site. How can I ...
0
votes
2answers
885 views

update_user_meta not updating

I'm trying to force password change upon first user login, which overall is not working, but so far I find a problem update_user_meta() is not updating at all, this is my code: function ...
1
vote
1answer
322 views

Looking for a hook for post.php

First time posting here... I am trying to figure out if there is a hook or action that I can use when a user goes to wp-admin/post.php... Basically when the user goes to post.php I want to check if ...
4
votes
1answer
703 views

How to change “Draft” string for status of custom post type to “Unavailable”?

ANSWER MOD: just an important mod to the chosen answer: // check if you actually have drafts; also avoids extra '|' separator if (isset($views['draft'])) { // 'Drafts' should be added (and come ...
0
votes
1answer
246 views

do add_action on condition

This snippet for example will email on EVERY post: function email_friends( $post_ID ) { $friends = 'bob@example.org, susie@example.org'; wp_mail( $friends, "sally's blog updated", 'I just put ...
0
votes
1answer
74 views

Wordpress Plugin Receive a Link

I'm writing a Wordpress plugin. The plugin should allow every user to rate posts (1 to 5 stars). What actually works is to read the rating from storage and show the stars. So there are five <a> ...
0
votes
1answer
59 views

Running a function with args in add_action()

I've created a plugin, and it has a function that takes two args, like so: process($tokens, $payloads); ... would this work? : add_action ( 'publish_post', process($tokens, $payloads) ); Many ...
3
votes
1answer
931 views

Create posts on user registration

How can I create let say 3 posts after the user finish the registration ? The ideal outcome would be to create 3 posts using the user as the author of the posts and with some pre-defined values. ...
1
vote
1answer
108 views

Valid filenames for add_action's first parameter

Some examples in WordPress' docs pass a filename to add_action rather than an action name. For example, add_action( 'load-post.php', 'callback' ); add_action( 'load-post-new.php', 'callback' ); ...
4
votes
1answer
161 views

Store source permalink on XMLRPC calls

In a theme I'm developing, I need to link to the source post when the post has been stored using XMLRPC. That implies that every time Wordpress asks for a permalink (using get_permalink()) the theme ...
-1
votes
1answer
448 views

publish_post action doesn't work

i'm developing a small plugin which will send email to users when a new magazine is published. i made a post type name "magazine" on the theme functions.php. and i wrote a plugin for email ...
2
votes
3answers
2k views

A Post is saved twice or more during add_action(save_post)

I have added a custom meta box for advanced information for a specific post category, to my create new post page. Now I recognize, that if I save the post, it writes 2 entries in the db with 2 ...
1
vote
1answer
285 views

Which action does wp_update_user triggers?

I am working modifying an ecommerce plugin, and it makes uses of wp_update_user() function, and everytime the function runs another table (created by the plugin), gets updated too. The problem is that ...
-1
votes
1answer
89 views

Action while post is being published

I modified the wordpress admin with a plugin I wrote, and my last problem is that there's no action anymore while the post is being updated or published in the admin. I looked around for a function or ...
0
votes
1answer
41 views

Create WordPress taxonomies based on theme settings

Is it possible to create taxonomies based on theme settings? That is, are theme settings actions run before taxonomies / post types are initialized?
4
votes
1answer
94 views

Getting the action's tag name within the action

There's a function attached to a set of actions, like this: add_action('some_tag', 'the_function'); function the_function($maybe_some_vars){ // ... } Is it possible to find out the action name ...
1
vote
3answers
592 views

Is there a recover_post hook to go with trash_post hook?

I'm using the trash_post hook to set a flag in a custom table to indicate that this item is "deleted", but when the user chooses to restore that post, what hook can I use for that? I couldn't find ...
4
votes
1answer
105 views

How Do I Load My Action Earlier Enough?

With add_action, I want to intercept as early as I can in my plugin and send a 304 Not Modified header per some rules. Does anyone know what the order is of events? When I view this page, it seems to ...
0
votes
2answers
2k views

How to use create_term, edit_term, delete_term actions?

I've created a Custom Taxonomy and I want to hook a function when User adds new Term to my Custom Taxonomy. Can someone please show me how to use following actions in Wordpress? create_term ...
9
votes
2answers
2k views

Why do some hooks not work inside class context?

I'm pretty stumped on this one. I'm using add_action inside my plugin class to do certain things- add scripts & styles to the head, wp_ajax, etc. Here's the actions, in the __construct: function ...
1
vote
1answer
47 views

add_actions called from functions.php not returning good values

I am trying to add some security/acccess prevention to my site via the functions.php. However whenever I try to add through functions.php (instead of as a plugin, which I've done in the past) it ...
0
votes
3answers
784 views

How to get post ID with hooks publish_post, new_to_publish, etc

I have two plugins, one uses the function wp_insert_post(), the other has a code like this: add_action('future_to_publish', 'myFunc', 10, 1); add_action('new_to_publish', 'myFunc', 10, 1); ...
0
votes
1answer
2k views

is there an update_post_meta action

Are there any actions I can hook into for update_post_meta()? I don't see anything obvious in the source. Woocommerce lets you change the featured status of items via ajax from the edit screen. I ...
9
votes
4answers
2k views

after_setup_theme always runs

I am setting up a child theme for some of my faculty members, and as a part of the theme, I would like a handful of plugins to be activated at the time that the theme is activated. So, naturally, I ...
0
votes
1answer
51 views

How do i know which action / filters are called when i call get_option()

I need to know which action / filters are called when i do a get_option() call, how can i do that?
5
votes
1answer
916 views

Difference between do_action('admin_enqueue_scripts', $hook_suffix) and do_action(“admin_print_styles-$hook_suffix”) syntax

Source ref: do_action('admin_enqueue_scripts', $hook_suffix); do_action("admin_print_styles-$hook_suffix"); Laying aside the obvious difference in base action ( admin_enqueue_scripts vs ...
1
vote
1answer
734 views

Get the post_id of a new post

There are several ways to get the id of a post after it has been saved (auto, etc.), but is there a way to get the post id immediately after you create a new post? I am trying to create a directory ...
1
vote
1answer
812 views

Add something to beginning of content with add_action('the_content')?

I'm using add_action('the_content', 'myFunction', 10) to append data to the end of the content. How can I place content at the beginning of the content?
0
votes
2answers
1k 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
112 views

Bug: Post needs to be updated twice when adding action for save_post hook

My function does exactly what I want it to do: I'm trying to add/update meta fields in another post type when an "events" post is saved. Except the post needs to be updated twice for the information ...
0
votes
2answers
979 views

When is admin_init Action ran?

I have this function below that is called with the admin_init Action function my_flush_rewrites() { global $wp_rewrite; $wp_rewrite->flush_rules(); } Like this ...
2
votes
1answer
480 views

add_action 'manage_posts_custom_column' in a class [closed]

I think this may be more of a general php question but I am posting it here as it relates to a WP function. I am having some issues with an add_action on manage_posts_custom_column inside a class. ...
8
votes
5answers
6k 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
1answer
51 views

How can I get more out of `$post` in an `add_action` callback?

I have the following action callback set up: function abc_save_post($post_id, $post) { // do stuff echo '<pre>'.print_r($post,true).'</pre>'; } add_action('save_post', ...
2
votes
2answers
2k views

Why is `add_meta_box` not working?

I'm trying to add some meta fields to a WPSC product using the following code: /** * data callback */ function abc_callback($object, $box) { echo 'callback executed!'; } /** * add custom ...
1
vote
4answers
274 views

Remove action from shortcode

There is add_action() function inside function which is callback for add_shortcode(). Any idea how to remove this action with the help of custom plugin? Should I hook to any action which is called ...
2
votes
1answer
2k views

How can I remove “Proudly powered by WordPress” from twentyeleven without modifying footer.php?

How can I remove "Proudly powered by WordPress" from twentyeleven without modifying footer.php, and without creating a child theme? I'm looking for a php command, such as add_action, remove_action, ...