Production > Let your students know their post is live
If you work with drafts from students and then publish, here’s a bit of code for functions.php that will send the author an e-mail once the post is live.
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');
SOURCE: WPRecipes.(via Cats Who Code)
- Semper Gumby
Conversation
Archives
