How to: Automatically notify your members on new posts

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.wprecipes.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.

Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!

How to: Automatically notify your members on new posts

Daily Email Newsletters

Weekly Email Newsletters

Subscribe to receive the latest design and creative business news, tutorials, and resources delivered to you via email—either daily (below) or weekly, to your computer, tablet, or mobile phone.

IMPORTANT NOTE: The newsletters and subscription confirmation email will be sent from the address briefing@iampariah.com. Please be sure to whitelist that address in your anti-spam filters. Check your Junk Mail or Spam folder if you miss an email prior to whitelisting briefing@iampariah.com.

Privacy and CAN-SPAM Compliance

All Pariah Burke newsletters comply with the U.S. CAN-SPAM Act. The newsletter even uses a third-party ESP to audit and ensure its compliance with CAN-SPAM. And your privacy is assured: your email address and other information will never be sold or given away.