Pages

email notification publish post in wordpress

Wednesday, 22 January 2014

email notification publish post in wordpress
publish post to send mail users in wordpress

function email_me($post)  {
global $post;
global $wpdb;
/*author*/
   $user_id = $post->post_author;
   $table_name = $wpdb->prefix . "subscribe_users";
   //$emails = $wpdb->get_results($wpdb->prepare( "SELECT subscriber_email FROM $table_name WHERE status = %s AND author_id = %d",'active',$user_id));
   $emails = $wpdb->get_results($wpdb->prepare( "SELECT subscriber_email FROM $table_name WHERE author_id = %d AND status = %s",$user_id,'active'));
  foreach($emails as $email) {
    $postMessage = $post->post_title;
    wp_mail($email->subscriber_email, "Blog Post", $postMessage);
}
    return $post;
}
add_action ( 'publish_post', 'email_me' ); 
 

Most Reading