How to automatically contact your employees by email when an article is published ?

If you have a blog with multiple authors, as with WordPress School, the School Cash or Gambling School, manage all content and team members can be a very complex process. One of the most interesting features of having a blog with multiple authors, is the ability of your team members receive automatically an email every time an article written by them is published on your WordPress blog. We work in an educational network of blogs with various authors, we feel the need to warn each whenever an article is published. To do this, the fellow wprecipes revealed a very interesting feature that allows you to contact a basically any employee so one of his article is published on your blog, ensuring that the author is aware of the publication of his text.




How to automatically contact your employees by email when an article is published
This trick has nothing complicated, really. You just copy and paste the code into the functions.php file of your template. If your WordPress Theme has no functions.php file, you must create a file with that name, write to the .php extension and paste this code inside. Save the document, upload it to your server, and the functionality is working. Simple like that!
function wpr_authorNotification($post_id) {
   $post = get_post($post_id);
   $author = get_userdata($post->post_author);




   $message = “
      Olá “.$author->display_name.”,
      O seu artigo, “.$post->post_title.” acabou de ser publicado. Obrigado por seu texto!
   “;
   wp_mail($author->user_email, “Seu artigo foi publicado”, $message);
}
add_action(‘publish_post’, ‘wpr_authorNotification’);
You can change the ” Hello ” text, ” Your article,” ” has just been published. Thank you for your text “and also” Your article was published , ” by others who find it more interesting to send by email to its employees. We have created these only as a feature of the illustration, but you must edit them according to your needs . Has however special care not to delete any of the Pelicas or codes governing the proper operation of the function.




LEAVE A REPLY

Please enter your comment!
Please enter your name here