Skip to content

Instantly share code, notes, and snippets.

@ekka21
Created June 21, 2012 14:26
Show Gist options
  • Save ekka21/2966035 to your computer and use it in GitHub Desktop.
Save ekka21/2966035 to your computer and use it in GitHub Desktop.
Wordpress: send email to subscriber when the post is published.
//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, SUBJECT, CONTENT);
return $post_ID;
}
add_action('publish_post', 'email_members');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment