lacee1986
8/9/2016 - 2:02 PM

Email users when new post published

Email users when new post published

add_action('publish_post', 'email_members');
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;
}