1

I'm looking for an action hook to link my function to when a completely new post is created with a status of pending?

I'm aware of 'save_post' and others but want to target specifically when a post is new.

Found this on a previous question:

add_action('new_to_publish', 'your_function');
add_action('draft_to_publish', 'your_function');
add_action('pending_to_publish', 'your_function');

but could do with something like new_to_pending or similar?

Any suggestions would be great!

1

There's the following (/wp-includes/post.php - line 2985):

do_action( 'transition_post_status', $new_status, $old_status, $post )

0
1

Funny, I found this whilst searching for the same question over three years later.

I thought I'd answer this incase I find it again in another three years...

Take a look at the docs here

The action you need is:

{status}_{post_type}

So for an event post type:

function pendingPost($post)
{
   // do something... 
}
add_action('pending_event', 'pendingPost', 10, 1);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.