Do you ever wished to be able to automatically send an email to your registered users and notify them of a new post on your WordPress blog? If yes, just read this recipe and lear how to do it easily!
Just paste the following code on your functions.php file:
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.CodeRevolution.com'); return $post_ID; } add_action('publish_post', 'email_members');
Once saved, all registered users will receive an email when a new post is published.
This recipe is inspired from an example found in WordPress Codex.
