iBlognet

Auto Email Guest Authors When Their Post is Published or Rejected

by Sahil Umatia

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

/* 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');

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

/* 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');

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 »


Sahil is the founder and editor of iBlognet. He is a freelance writer on topics related to Website Optimization (SEO), Blogging, and Tech. He also specializes in SEO, HTML, CSS and Photoshop. Sahil has written 277 fantastic article(s) on iBlognet.


Author Site » Know me More

Author Connect »

{ 11 comments… read them below or add one }

1 avnish gautam

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

Reply

2 Student

Hey,

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

Help appreciated!

Stu

Reply

3 Sahil Umatia

Just paste the code in custom-functions.php

Reply

4 Ammar Ali

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

It gives php error!
Ammar Ali invites you to read Cool Floating Recent Tweets Widget for BlogsMy Profile

Reply

5 Sahil

The code seems to be working fine.
Sahil invites you to read How To Add SEO Breadcrumbs in WordPressMy Profile

Reply

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

Reply

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.

Reply

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

Reply

9 Sahil Umatia

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

Reply

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…
Winson Yeung invites you to read How Facebook’s Graph Search Will Change The Search Engine LandscapeMy Profile

Reply

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

Reply

Leave a Comment

We're glad that you chose to leave a comment. This blog uses KeywordLuv. Enter YourName@YourKeywords in the "Name" field to take advantage of link juice for your anchor text. Please keep in mind that all comments are moderated. Let's have a meaningful conversation.

CommentLuv badge
This blog uses premium CommentLuv Premium which allows you to put your keywords with your name if you have had 1 approved comments. Use your real name and then @ your keywords (maximum of 2)

Previous post:

Next post: