I have this little bit of code that sends me an email whenever a new posts is published by an author, but I want to be alerted to posts in 'pending' status by contributors too.
add_action('publish_post', 'send_admin_email');
function send_admin_email($post_id){
$to = '[email protected]';
$subject = 'New Post on The Articist';
$message = "new post published at: ".get_permalink($post_id);
wp_mail($to, $subject, $message );
}
Can I have emails sent to me so I'm informed when posts are pending?
Code from userabuser's first solution, this doesn't seem to actually send emails(yes, I have changed it to my actual email address in the functions.php).
add_action( 'transition_post_status', 'pending_post_status', 10, 3 );
function pending_post_status( $new_status, $old_status, $post ) {
if ( $new_status === "pending" ) {
function send_pending_email($post_id){
$to = '[email protected]';
$subject = 'New Pending Post';
$message = "new post Pending";
wp_mail($to, $subject, $message );
}
}
}