I've found this code that worked perfectly for notifying admin when a post is updated, but it's annoying the admin because she's getting emails for all updates and she only wants notifications for posts that are pending. I cannot figure out how to do this.
Here's my code so far:
add_action( 'save_post', 'my_project_updated_send_email' );
function my_project_updated_send_email( $post_id ) {
//verify post is not a revision
if ( !wp_is_post_revision( $post_id ) ) {
$post_title = get_the_title( $post_id );
$post_url = get_permalink( $post_id );
$subject = 'A post has been updated';
$message = "A post has been updated on your website:\n\n";
$message .= "<a href='". $post_url. "'>" .$post_title. "</a>\n\n";
//send email to admin
wp_mail( 'amdin@test.co.uk', $subject, $message );
}
}
I've tried changing add_action('save_post'
to add_action('on_publish_pending_post'
But that didn't work. I tried just 'pending', but that didn't work. I'm a bit stuck.