Email Post Contributors When Their Posts Are Published

 In Wordpress Admin

As you will know if you read this post, I am a huge fan of the Edit Flow plugin. However, if you don’t need the extensive features that it offers, and instead are just looking for a way to automatically email contributors when their posts are published, just use this quick and easy code snippet:

function wpr_authorNotification($post_id) {
$post = get_post($post_id);
$author = get_userdata($post->post_author);

$message = "
Hi ".$author->display_name.",
Your post, ".$post->post_title." has just been published. Well done!
wp_mail($author->user_email, "Your article is online", $message);
add_action('publish_post', 'wpr_authorNotification');

Learn how to display private posts to logged in users @  – Nuno Sarmento

Recommended Posts

Leave a Comment

Start typing and press Enter to search