Notify members on new posts

Adding this PHP code snippet to the functions.php of your wordpress theme will notify users of new posts. Please note that this snippet is best used for low volume sites. Large websites should consider alternative options.

 

 

 

function email_members($post_ID)  {
global $wpdb;
$usersarray = $wpdb->get_results("SELECT user_email FROM $wpdb->users;");
$users = implode(",", $usersarray);
mail($users, "New WordPress post online", 'A new post has been published on http://www.wpsnipp.com');
return $post_ID;
}
add_action('publish_post', 'email_members');

Be Sociable, Share!

Leave a comment