I am using the code below on a multi user blog for sending a email notification to users when new post is published . But the problem is it is sending notification only when a Administrator and Editor is posting. I want to send notification when a Administrator, Editor, Author and Contributor post any thing. So what should I change of the code below for work for this, Please help urgently:
function new_mail_from($old) {
return '[email protected]';
}
function new_mail_from_name($old) {
return 'Postmaster - BIZCATALYST360°';
}
/** Notification Upon post Pubished */
function authorNotification( $new_status, $old_status, $post ) {
if ( $new_status == 'publish' && $old_status != 'publish' ) {
$author = get_userdata($post->post_author);
$message = "
Hi ".$author->display_name.",
New post, ".$post->post_title." has just been published at ".get_permalink( $post->ID ).". ";
wp_mail($author->user_email, "$post->post_title", $message);
}
}
add_action('transition_post_status', 'authorNotification', 10, 3 );