Automatically New Post Notify your WordPressme register mbers
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? See you 2 codex. You can following any one codex. Only copy and pest your functions.php file just any 1 codex.
Just paste code on your functions.php file:
Following codex (1)
function newpostnotify($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 post have been published on the http://yourdomain.com');
return $post_ID;
}
add_action('publish_post', 'newpostnotify');
Following codex (2)
function newPostNotify($post_ID)
{
if(wp_is_post_revision($post_ID))return;
global $wpdb;
$get_post_info = get_post($post_ID);
if($get_post_info->post_status == 'publish' && $_POST ['original_post_status']!= 'publish'){
$wp_user_email =$wpdb->get_results("SELECT DISTINCT user_email FROM $wpdb->users");
foreach ($wp_user_email as$email) {
$subject= 'A new post have been published on the http://yourdomain.com';
$message='View this new post now'.get_permalink($post_ID);
wp_mail($email->user_email,$subject,$message);}}
}
add_action('publish_post','newPostNotify');
Just paste code on your functions.php file:
Following codex (1)
function newpostnotify($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 post have been published on the http://yourdomain.com');
return $post_ID;
}
add_action('publish_post', 'newpostnotify');
Following codex (2)
function newPostNotify($post_ID)
{
if(wp_is_post_revision($post_ID))return;
global $wpdb;
$get_post_info = get_post($post_ID);
if($get_post_info->post_status == 'publish' && $_POST ['original_post_status']!= 'publish'){
$wp_user_email =$wpdb->get_results("SELECT DISTINCT user_email FROM $wpdb->users");
foreach ($wp_user_email as$email) {
$subject= 'A new post have been published on the http://yourdomain.com';
$message='View this new post now'.get_permalink($post_ID);
wp_mail($email->user_email,$subject,$message);}}
}
add_action('publish_post','newPostNotify');
Comments
Post a Comment