Created
March 14, 2012 17:53
-
-
Save adamcbrewer/2038212 to your computer and use it in GitHub Desktop.
WP: Email Users On Post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function email_members($post_ID) { | |
global $wpdb; | |
// fetch the list of users registered | |
foreach( $wpdb->get_results("SELECT user_email FROM $wpdb->users;") as $key => $object) { | |
$user_emails[] = $object->user_email; | |
} | |
$users = implode(',', $user_emails); | |
$subject = ""; | |
$message = ""; | |
$headers .= 'From: ' . "\r\n"; | |
mail($users, $subject, $message, $headers); | |
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