Whenever you publish a new post in your blog, you do wish to notify your members. Well this can be done automatically by simply copying and pasting the snippet below to your theme’s functions.php file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | function email_members($post_ID) { global $wpdb; $usersarray = $wpdb->get_results("SELECT user_email FROM $wpdb->users;"); $users = implode(",", $usersarray); mail($users, "New WordPress recipe online!", 'A new recipe have been published on http://www.wprecipes.com'); return $post_ID; } add_action('publish_post', 'email_members'); |
Snippet Source/Credit: WordPress Codex