How to Automatically notify users on new post

Do you ever wish to send your registered user’s an email whenever you do a new post , well this is basically very useful if you have a big list of user registered on your WordPress blog

So now lets implement this hacks go to functions.php and add the below code

function email_members($post_ID)  {
    global $wpdb;
    $usersarray = $wpdb->get_results("SELECT user_email FROM $wpdb->users;");
    $users = implode(",", $usersarray);
    mail($users, "New Post on WordPress Den", 'A new post have been published on');
    return $post_ID;

add_action('publish_post', 'email_members');

Just edit the above code at line 5 to what ever you want


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>