iBlognet

Auto Email Guest Authors When Their Post is Published or Rejected

by Editor

WordPress-Email-AuthorAccepting guest post on a blog is a great way to get more traffic, popularity and having constant flow of content, thus keep your blog alive with fresh content. And any good blog that gets dozens of guest articles on monthly basis, it’s necessary to notify each authors about their article status. And sending an email to each author seems to be more time consuming.

While there are many WordPress plugins available that can automatically send email to the authors if their article is published or rejected. But In this post I will show you, how you can do this without any plugin.

Auto Send an Email When a Post is Published

Copy Paste the following code in function.php

[php]/* POST PUBLISHED EMAIL NOTIFICATION */
function authorNotification($post_id) {
global $wpdb;
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$message = ”
Hi “.$author->display_name.”,

Well done! Your post, “.$post->post_title.” has been reviewed and just been published.
“;
wp_mail($author->user_email, “Your article status”, $message);
}
add_action(‘publish_post’, ‘authorNotification’);[/php]

Once saved, the author will automatically receive an email when the post has been approved and published. You can customize the message as you need.

Auto Send an Email When a Post is Rejected

Copy Paste the following code in function.php

[php]/* POST TRASHED EMAIL NOTIFICATION */
function authorNotification2($post_id) {
global $wpdb;
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$message = ”
Hi “.$author->display_name.”,
We are sorry to inform you that your article, “.$post->post_title.” has been declined. We strongly recommend you to go through the guest posting guidelines before you submit an article again.
“;
wp_mail($author->user_email, “Your article status”, $message);
}
add_action(‘trash_post’, ‘authorNotification2’);[/php]

Once saved, the author will automatically receive an email that the post has been trashed. You can customize the message as you need.

If you have any query or question, you can leave a comment below or contact me using the contact form. If you enjoyed the post, please consider sharing it.

Article by »


Admin and Editor of iBlognet iBlognet has written 294 fantastic article(s) on iBlognet.


Author Connect »

1 avnish gautam

Very nice and unique post. Thanks for sharing this useful information about auto notify author post published and rejected. Thanks.

2 Student

Hey,

Can you tell me how to add this code in thesis theme?

Help appreciated!

Stu

3 Sahil Umatia

Just paste the code in custom-functions.php

4 Ammar Ali

The code “Auto Send an Email When a Post is Published” is not working! 🙁

It gives php error!

5 Sahil

The code seems to be working fine.

6 Andrew Corey

Cool! This is a nice post. I am looking for that kind of post.
Andrew Corey invites you to read Dallas Moving

7 Tania

Nice post with excellent help for all of those people requiring email notifications to guest authors. Anything that helps save time it is worthy to be considered, maintaining a successful blog can be a time consuming activity, this is a great piece of code.

8 Ben

Awesome stuff, I pasted the code and it works perfectly. Question though:

How would I be able to send a personalized message with this when I reject the post, like “please change the second heading in this post”.

According to the code it will just give the general message everytime.

Thoughts?

Thanks,

Ben

9 Sahil Umatia

Posiible.. But I have to work out on the code to make it working…

10 Winson Yeung

Do you have any wordpress plugin that will allow admin to send an email to guest author when their article is published or rejected and able to add in the reason?

Because I dont want to mess with the coding…

11 Darcy

Hey Sahil,

I’ve been tossing around the idea of having some people do guest posts for my site but the idea of waking up every day and having to wade through/respond to email after email is a daunting on if we’re being honest.

I would never want to just reject a guest post by not responding – after all, the author put in the time and the effort to write it all up – but I think you’ve served up a solution for me here.

I appreciate the heads up, buddy!

Darcy

12 Seth Resler

This is great – will it work for custom post types?

13 Deepak Singh

Nice article man!! Those who are facing difficulty in adding this snippet in fucntions.php can install Peter’s Collaboration E-mails Plugin.

14 Deepak Singh

Cool Snippet bro,going to try this on my blog now. Looks like now we dont have to install 3rd party plugin for sending notifications to authors whether there article is approved or deleted.

Comments on this entry are closed.

Previous post:

Next post: