Best 2 Know

The Ultimate Blogging Resource

  • Advertising
  • WebHosting
  • Contact Us
  • Blogger
    • Blogger Templates
    • Blogger Tutorials
  • Browser
    • Firefox
    • Google Chrome
  • Google
  • Internet
    • Facebook
    • Twitter
  • Thesis
  • Windows
  • WordPress
    • WordPress Themes
    • WordPress Plugins
  • More
    • Linux
    • Review
    • Solutions
    • Announcements

How to Automatically notify users on new post

Do you ever wish to send your registered user’s an email whenever you do a new post , well this is basically very useful if you have a big list of user registered on your WordPress blog

So now lets implement this hacks go to functions.php and add the below code

function email_members($post_ID)  {
    global $wpdb;
    $usersarray = $wpdb->get_results("SELECT user_email FROM $wpdb->users;");
    $users = implode(",", $usersarray);
    mail($users, "New Post on WordPress Den", 'A new post have been published on http://www.wpden.net');
    return $post_ID;
}

add_action('publish_post', 'email_members');

Just edit the above code at line 5 to what ever you want

Subscribe via Email

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to print (Opens in new window) Print
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to email a link to a friend (Opens in new window) Email

Related

June 23, 2011 Ritesh Sanap WordPress Notify users, Notify wordpress users, Tricks, wordpress, wordpress hacks

Comments

  1. Cebu Tech Blogger says

    July 26, 2011 at 2:38 am

    Hi, how about if you just want to notify specific users on a new post? Is it possible with the code above?

    Reply
    • Ritesh Sanap says

      January 20, 2012 at 7:05 pm

      No the above code only sends mails to all the users

      Reply
  2. mirditori says

    April 5, 2014 at 6:46 am

    Adding to this conversation another plugin i found is this
    http://codecanyon.net/item/live-post-page-product-notification/7365533

    Can you tell me a bit more about that ?

    Regards

    Reply
    • Ritesh Sanap says

      April 12, 2014 at 9:22 am

      the details regarding this plugin can be found on its descriptions page, the plugin shows live notification of the new posts unlike sending email, you can think of the plugin like showing facebook updates.

      Reply
  3. Bruno Accioly says

    May 7, 2014 at 1:43 pm

    What if I wanted to make show a hidden DIV for the user every time a post was published?

    Any hints on that?

    Reply
    • Ritesh Sanap says

      July 14, 2014 at 11:18 am

      What you are saying is possible but it is more complex where it requires a seperate table in mysql to keep track of users who have viewed post and AJAX (Optional) to notify users on the site in real time. whereas the above solution is quite simple and uses WordPress.

      if you want live notifications follow the link posted by “mirditori” in the comments. I guess that will be your best bet, you can install that plugin and afterwards you can tweak it to show the div like you want.

      Reply

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Post navigation

Previous Previous post: WordPress SEO Plugin by Yoast
Next Next post: BlackSpire WordPress Theme

Currently Trending

  • How to download Specific parts of YouTube videos
    How to download Specific parts of YouTube videos
  • Windows Vista CD key
    Windows Vista CD key
  • How to retrieve my Demonoid username
    How to retrieve my Demonoid username
  • How to add Logo to Thesis theme
    How to add Logo to Thesis theme
  • How to Delete Feedbacks from JetPack Contact Form
    How to Delete Feedbacks from JetPack Contact Form
  • List Of All 255 Keyboard All Alt Key Codes
    List Of All 255 Keyboard All Alt Key Codes
  • h4x0r ( Hacker ) - Blogger Template
    h4x0r ( Hacker ) - Blogger Template

Get Latest post in your Inbox

Random Posts

WebHosting Comparison

December 15, 2010 By Ritesh Sanap Leave a Comment

BlackSpire WordPress Theme

June 25, 2011 By Ritesh Sanap 8 Comments

How to change Blogger Template without deleting widgets ?

March 9, 2009 By Ritesh Sanap Leave a Comment

How to create transparent png with photoshop

July 11, 2009 By Ritesh Sanap 4 Comments

[How-To]View Locked orkut Albums

February 29, 2008 By Ritesh Sanap Leave a Comment

WordPress

HTTP2 Server Push for W3 Total Cache Minify plugin

August 17, 2016 By Ritesh Sanap 5 Comments

How to Disable Emojis in WordPress

January 6, 2016 By Ritesh Sanap Leave a Comment

JetPack Related posts and Sharing not working with NGINX

November 10, 2015 By Ritesh Sanap Leave a Comment

Simply Pure – WordPress Theme

November 2, 2014 By Ritesh Sanap 2 Comments

Advanced What should we Write about next? – WordPress Plugin

July 28, 2014 By Ritesh Sanap Leave a Comment

How to Disable Self Pingback or TrackBack

January 16, 2014 By Ritesh Sanap Leave a Comment

BlueStrap – WordPress Theme

January 1, 2014 By Ritesh Sanap 15 Comments

How to Create Multiple Excerpts in WordPress

December 24, 2013 By Ritesh Sanap Leave a Comment

How to Disable Auto Update in WordPress

November 21, 2013 By Ritesh Sanap Leave a Comment

How to Delete Feedbacks from JetPack Contact Form

November 19, 2013 By Ritesh Sanap 9 Comments

Recent Posts

  • HTTP2 Server Push for W3 Total Cache Minify plugin
  • How to show hidden files and folders in Mac OS X
  • How to Disable Emojis in WordPress
  • Canva – Online Photo Editor
  • JetPack Related posts and Sharing not working with NGINX

Archives

Recommends

  • DigitalOcean – Cloud Hosting
  • Dropbox – Cloud Storage
  • Elegant Themes – WordPress Themes
  • LastPass – Password Manager
  • Like us on Facebook
  • Follow on Twitter
  • +1 on Google
  • Subscribe via Email
  • RSS Feed

© 2025 Best 2 Know · All Rights Reserved · We ♥ DigitalOcean