Email Post Contributors When Their Posts Are Published

 In Functions, Wordpress Admin, WordPress Email

Email Post Contributors When Their Posts Are Published

 

This WordPress code snippet below will email the Post Author a “post published successful” confirmation for every post published.
The code can be also used for the WordPress admin to check when, how and whats is published to the website, this WordPress code snippet can be useful if you want to track down publishers work.

Email Post Contributors When Their Posts Are Published code snippet:

function ns_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', 'ns_authorNotification');

Learn how to display private posts to logged in users @ https://www.wp-code.uk  – Nuno Sarmento

Send me a message if you are interested to publish your WordPress code snippet here on my website, I will be more than happy to have your WordPress code snippet published on my Website WordPress code snippets section.

Are you tired and worried about your WordPress site security? Pease have a look on my Support & Maintenance Plans. My Support & Maintenance Plans can be tailored to your specific needs, you just need to drop a line on my contact form (here) and I will get back to you ASAP.

Recommended Posts

Leave a Comment

Start typing and press Enter to search