Ever thought about emailing authors when their articles get published on your WordPress platform?
For those running multi-author blogs, sending notifications to authors when their blog articles are posted can be useful. It not only keeps them informed but also promotes engagement on your site since authors can share their content quickly and participate in discussions.
In this piece, we’ll delve into how to mail authors upon publication of their articles on WordPress.
Why Should Authors Be Notified of Their Article’s Publication on WordPress?
Sending notifications to authors when their articles go live on your WordPress blog enables them to promote their posts immediately on different social media platforms and engage with readers in the comment section.
Furthermore, these notifications keep authors abreast of the status of various posts, which helps establish trust within your team by demonstrating that you value each writer’s input on your multi-author blog.
Immediately notifying authors of post publication not only allows them the chance to proofread their content and correct any errors or typos but also proactively prevents visitors from seeing these errors.
With that in mind, let’s examine how to effectively email authors when their articles are posted in WordPress. You can use the links below to jump to your preferred method:
Method 1: Using a Plugin to Notify Authors When Their Article Gets Published in WordPress
If you’d rather utilize a plugin to inform your authors, then this is the method for you.
Initially, you’ll need to install and activate the PublishPress Planner plugin. Kindly refer to our beginner’s guide to learn how to install a WordPress plugin.
After activating the plugin, navigate to the Planner » Settings page located on the WordPress admin sidebar and switch to the ‘Notifications’ tab.
Once that’s done, input the admin email address meant to dispatch emails to your authors into the ‘Email from’ option field.
Subsequently, tick the ‘Always notify the author of the content’ option to dispatch emails to authors each time their posts are published on your blog.
If you’d also like to inform the users who edited the post, you can tick the ‘Always notify users who have edited the content’ option.
Upon completing your settings adjustments, click ‘Save Changes’ to preserve your changes.
Now, when you publish a post by an author, they will instantly receive an email notification that looks as follows:
Method 2: Manually Email Authors Upon Article Publication on WordPress Using Code
If you’d rather avoid using a plugin, you also have the option to automatically mail authors by adding code to the functions.php file of your theme.
However, do note that even the slightest error while adding code can impair your website and render it inaccessible.
That’s why it necessitates using WPCode. This leading WordPress code snippets plugin makes incorporating custom code into your website easy and safe.
To begin, you must install and activate the WPCode plugin. You can refer to our comprehensive guide on how to install a WordPress plugin for more information.
Note:For this tutorial, you can also use WPCode’s free version. However, to access a suite of additional features like a code snippets library, conditional logic, CSS snippets, and more, consider upgrading to the pro version.
Once you’ve activated the plugin, navigate to the Code Snippets » + Add Snippet page from the WordPress dashboard. Proceed by clicking on the ‘Use Snippet’ button under the ‘Add Your Custom Code (New Snippet)’ option.
This will take you to the ‘Create Custom Snippet’ page, where you must start by adding a title for the code snippet.
Subsequently, from the Code Type dropdown menu on the right, select the ‘PHP Snippet’ option.
Next, copy the following custom code and paste it into the ‘Code Preview’ box:
function notifyauthor($post_id) {
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$subject = "Post Published: ".$post->post_title."";
$message = "
Hi ".$author->display_name.",
Your post, "".$post->post_title."" has recently been published.
View post: ".get_permalink( $post_id )."
Thanks"
;
wp_mail($author->user_email, $subject, $message);
}
add_action('publish_post', 'notifyauthor');
This code is executed whenever a new post is published on WordPress, notifying the author via an email using the subject and message defined in the code. You are free to modify the subject and message parameters to suit your needs.
After making the necessary adjustments, scroll down to the ‘Insertion’ section and opt for ‘Auto Insert’ mode. Stores your settings with ‘Save Changes’.