Automatically Notify Your Members on New Wordpress Posts?

Maxoq

Well-known member
Registered
Joined
Feb 25, 2015
Messages
520
Points
28
I have a Wordpress with more than 500+ members, I posted some new Wordpress blog posts weekly, normally I will submit them to social networks to increase traffic for them but it is possible to notify my members when my WP blog has new posts?
 

MooseLucifer

Well-known member
Registered
Joined
May 20, 2016
Messages
149
Points
28
Increasing traffic is always the first thing you need to do for websites. Beside of sharing on major social networks such as Facebook, Twitter, or Google plus, Linkedin...etc also a good way then automatic emailing to anyone who has ever subscribed to your site will make your work optimized and that will help to make visitors back to your sites. If you are using WordPress for your website or blog, this code will be really useful to email your subscribers about new posts.

Find functions.php file in theme folder that you are using, after pasting the code below.

PHP:
<?php
function email_members($post_ID)  {
    $wp_user_search = new WP_User_Query( array( 'fields' => array('user_email') ) );
    $usersarray = $wp_user_search->get_results();
    $arrUsers = array ();
    for ($arr = $usersarray, $mU = count ($arr), $iU = 0; $iU < $mU; $iU++) {
        $arrUsers&#91;&#93; = $arr&#91;$iU&#93;->user_email;
    } // for
    $users = implode(",", $arrUsers);
    
    mail($users, "New post notification : " . get_bloginfo('name') , "A new post has been published on " . get_bloginfo('siteurl') );
    return $post_ID;
}
add_action('publish_post', 'email_members');
?>
Now when you have new posts on your blog, it will let them know about that.

Good luck.
 
Latest Threads
Recommended Threads

Latest postsNew threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top