Moderator
t-p
(@t-p)
from the description that looks like it will allow me to do what I want to do. But just in case that plugin stops getting updated, how do I do it in my code?
Moderator
t-p
(@t-p)
function notifyAdmins( $new_status, $old_status, $post ) {
if ( ($new_status == 'publish') && ($old_status != 'publish') ) {
$userQueryArgs = array(
'blog_id' => $GLOBALS['blog_id'],
'role' => 'administrator',
'meta_key' => '',
'meta_value' => '',
'meta_compare' => '',
'meta_query' => array(),
'include' => array(),
'exclude' => array(),
'orderby' => 'login',
'order' => 'ASC',
'offset' => '',
'search' => '',
'number' => '',
'count_total' => false,
'fields' => 'all',
'who' => ''
);
$adminstrators = get_users($userQueryArgs);
$recipients = array();
foreach ( $adminstrators as $admin ){
$recipients[] = $admin->data->user_email;
}
$message = "New post, ".$post->post_title." has just been published at ".get_permalink( $post->ID );
wp_mail($recipients, "New Post", $message);
}
}
add_action('transition_post_status', 'notifyAdmins', 10, 3 );