2012-03-06 #wordpress

Send Email To Wordpress Author On Post Publish

Here is a great Wordpress snippet for multi author blogs. This will automatically send an email to the author of the post once it has been published. It uses the Wordpress action of publish_post which runs after the post has been published. All you have to do is add the following into your functions.php page.

function 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 at ".get_permalink( $post_id ).". Well done!
   wp_mail($author->user_email, "Your article is online", $message);
add_action('publish_post', 'authorNotification');

Source: WordPress Essentials: The Definitive Guide To WordPress Hooks


Reliable uptime monitoring and instant alerts for any website downtime.

  • Uptime Monitoring
  • Performance Monitoring
  • SSL Certificate Alerts
  • Domain Monitoring
  • DNS Checker
  • XML Sitemap Monitoring