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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Start typing and press Enter to search

Let's work together

I'd love to work with you! Please fill out my project form to tell me more about your project/work. I reply to all enquiries within 48 hours.

Availability

  • June - Booked
  • July - Booked
  • August - Limited

Rates

  • My day rate is £300.
  • I can provide a fixed price for your work.
  • Projects start at around £2,000.

Header Enquiry Form

  • This form collects your name, email address and telephone number so that I can respond to the enquiry(ies) that you submit via this website. Please check my privacy policy for the full story on how I use, protect and manage your submitted data.