I'm working on a Wordpress / Woocommerce site where "Advertisers" can publish their own products.
There's a 2 step process to publishing their product, so when a user submits their product the status is set to "Pending Review", I've added a new publish status "Final Validation", Is there a way I can use something like the publish_post hook that I can use to email the author when we change the Publish status to "Final Validation"? I figured I would be able to easily edit the code below to just say "If status change = "Final Validation do this" but Im not really getting anywhere. Obviously the add_action shouldn't be "publish_post", but I'm not sure what it should be.
Can anyone help?
function notifyauthor($post_id) {
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$subject = "We are validating your post : ".$post->post_title."";
$message = "
Hi ".$author->display_name.",
Your product, \"".$post->post_title."\" is now in the final stages of being validated.
View post: ".get_permalink( $post_id )."
Thanks"
;
wp_mail($author->user_email, $subject, $message);
}
add_action('publish_post', 'notifyauthor');
do_action( "{$old_status}_to_{$new_status}", $post );but I don't really understand it, sorry, I'm not good with PHP - sleepyjones