Post Pic

Display the total number of users of your WordPress blog

If your blog allow user registration, what about displaying the total number of registered users? This simple code will allow you to do it easily.

To achieve this recipe, simply paste the following code anywhere in your theme files:

$users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");
echo $users." registered users.";

Once you saved the file and refreshed your blog, the total number of users will be displayed.

17 Responses

Apr 27 2009 21:06

Cool! And how many total users wprecipes.com have?

Apr 27 2009 23:08

@Alex Vorn: Currently, 595 members :)

Apr 28 2009 17:47

So easy? Thanks a lot ;)

Apr 28 2009 21:40

Another useful tip for those that like statistics and have big user database :)

Apr 29 2009 05:19

Great informations.Thanks for sharing.

Apr 29 2009 12:31

nice one..thanks

Apr 30 2009 01:02

Wow, so very simple!

Thanks mate, Off to try this one out now!

May 01 2009 16:00

very cool. once i get a “worthy” number of users i will expose the count!

May 08 2009 07:18

I assume this is for the registered users, not the subscribers like via Feedburner

May 08 2009 18:02

Slick. As soon as I get enough users to be proud of it, I’ll have to try this one. Good PR starts in your own blog!!!

Jun 02 2009 11:03

Great tip. I’d only try to be a little careful with using it just after starting your userbase. Because “we have 4 registered users” is just sad.

Jun 07 2009 21:03

Very Useful. Thanks a lot.

Jun 25 2009 09:55

Brilliant stuff! This was just what I was looking for. I was doing a search for counting in sql and stumbled across this. Thank you for your help. ;-)

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required