Display The Total Number Of Registered Users

WordPress-Christmas-09Anyone who operates a community using WordPress, and would like to display the total number of registered users, can easily and quickly use the following small code snippet.

It reads via SQL the content of the table “users“, and the numbers of IDs getting counted. This value simply gets wrapped around a text.

$myusers = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");
echo sprintf( __('We have %s registered user.', 'myTextDomain') , $myusers );

Comments are closed.


  1. Miss K

    this is very usefull (at least for me :-)!
    thank you…
    but i try to implement this into a php sidebar widget
    get_var(“SELECT COUNT(ID) FROM $wpdb->users”);
    echo sprintf( __(‘We have %s registered user.’, ‘myTextDomain’) , $myusers );
    and I get the following error :
    Fatal error: Call to a member function on a non-object in –/versatile-k/wp-content/plugins/php-code-widget/execphp.php(37) : eval()’d code on line 2

  2. wahnfried

    so i have the same problem, the snippet doesnt work in the sidebar.maybe you can help?

  3. Michael

    @wahnfried: Use

    global $wpdb;

    before query.

2 pingbacks

  1. Die Anzahl der registrierten Benutzer anzeigen | galuba dot net
  2. 11 Awesome Wordpress Development Blogs