Automatically Email Guest Authors When Their Posts Are Published

Today’s featured WordPress tutorial will surely be very helpful to blog owners who run a multi-authored blog or blogs with lots of guest authors. This useful snippet is taken from a portion of one of Daniel Pataki’s SmashingMagazine articles regarding WordPress hooks.

WP hooks Automatically Email Guest Authors When Their Posts Are Published

For now, let’s find out how you can automatically send emails to your various authors once their posts get published on your site. Believe it or not, all it takes is copying one short series of code (shown below this paragraph) and then pasting it on your functions.php file.

function wpr_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', 'wpr_authorNotification');

If you want to check out Daniel’s article about WordPress hooks, you can read all about it HERE. You can also find a more detailed explanation of the whole code above in that article.

Incoming search terms for the article:

Related Posts

Photoshop Tutorial: How To Combine A Crocodile And A Car

How to Create a Realistic Vinyl Record Design

Adding an Instagram-like Photo Filters in WordPress via Pressgram

Quick And Easy WordPress Tricks

No comments