Home / functions.php / Notify members on new posts
  • How to Notify members on new posts

    no thumbnail sorry: Notify members on new posts

    Adding this PHP code snippet to the functions.php of your wordpress theme will notify users of new posts. Please note that this snippet is best used for low volume sites. Large websites should consider alternative options.

    ( click code to copy )

    wordpress snippet : PHP

    function email_members($post_ID)  {
        global $wpdb;
        $usersarray = $wpdb->get_results("SELECT user_email FROM $wpdb->users;");
        $users = implode(",", $usersarray);
        mail($users, "New WordPress post online", 'A new post has been published on http://www.wpsnipp.com');
        return $post_ID;
    add_action('publish_post', 'email_members');

    ( WordPress codex functions, hooks, in this snippet. )

    publish_post, add_action, _e, wp,