I am working on a plugin that sent an email when a post is published using
add_action('save_post','my_function');
my_function($post_id)
{
//do everything here
}
its working fine whenever a new post is published or its being updated from quick edit,
but the problem is that its not working when a post is schedule for future publish, for this I googled it, and find the following
add_action('publish_future_post', 'my_function');
this is the same function as used for above action,
I also found following action on some results,
add_action('future_to_publish', 'my_function');
but the last 2 action not working , mean its not sending any email,
can anyone help me to figure it out ,
@Andrew Bartel
here is my complete function,
its my function , if you have any confusion in this please let me know.
On line 3 you’re checking the post_status of the post and explicitly checking for publish, which is only set for posts that (you guessed it) are published. When a post is scheduled to be published later, it’s status is set to future. For your example, the first three lines:
Let me know if that works for you.