Nothing complicated with this recipe. Copy the code below and paste it on your functions.php file. Then save the file, and you’re done!
function wpr_authorNotification($post_id) {
global $wpdb;
$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', 'authorNotification');
Thanks to Daniel Pataki for the great piece of code!
Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!
How to automatically email contributors when their posts are published