in 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

Upgrade to access all content on Paulund

Members unlock all tutorials and snippets

Access to all downloadable content

Access to code examples before others

Sign Up Now

Already a member? Login here

Subscribe To The Weekly Newsletter

Get weekly updates to your email