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.
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.
No comments
WP Plugins for Automatically Email Guest Authors « What I read I share
06.04.2012
[...] is an awesome plug in post from Blogfreakz explaining on how to Automatically Email Guest Authors When Their Posts Are Published with this feature it will really help the blog owners who has a mult-authored blog that has a lot [...]
There are no trackbacks to display at this time.