Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Show Total Number of Registered Users in WordPress

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

Have you ever wanted to show the total number of registered users on your WordPress site?

Social proof, like showing the number of registered users on your site, encourages others to sign up.

In this article, we will show you how to show the total number of registered users in WordPress.

How to Show Total Number of Registered Users in WordPress

We will cover two methods in this post, and you can use the quick links below to jump to the one you want to use:

Method 1: Show Registered User Count Using a WordPress Plugin

The first thing you need to do is install and activate the Simple Blog Stats plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, you need to visit the Settings » Simple Blog Stats page to configure the plugin settings.

Settings page for Simple Blog Stats

This plugin allows you to show different stats from your WordPress website.

You need to click on the shortcodes tab to expand it and then scroll down to the ‘number of users row.

Users shortcode settings

You will see the shortcode [sbs_users] with two text fields on both sides. These text fields contain HTML, and the plugin will add before and after the number of users.

By default, the shortcode will output HTML like this:

<span class="sbs-count-users">856</span>

If you are unsure, then copy the shortcode [sbs_users] and click on the ‘Save Settings’ button.

You can now add this shortcode to any WordPress post or page. You can also add it to a sidebar widget.

Edit the post or page and add the Shortcode block. After that, copy and paste your shortcode inside the block settings.

Add user count shortcode in block editor

Similarly, you can add the shortcode block in sidebar widgets, too.

Go to the Appearance » Widgets page and add the shortcode block where you want to display the user count.

User count displayed in sidebar widget

Method 2: Manually Show The Number of Registered Users in WordPress with Code

This method requires you to add code to your WordPress site.

You need to add the following custom code to your website. You can add it to your theme’s functions.php file or by using the WPCode plugin (recommended)

If you need help adding code, then follow our tutorial on how to safely add custom code in WordPress:

// Function to return user count
function wpb_user_count() {
$usercount = count_users();
$result = $usercount['total_users'];
return $result;
}
// Creating a shortcode to display user count
add_shortcode('user_count', 'wpb_user_count');

This code creates a shortcode [user_count] that you can use in your WordPress posts, pages, or a sidebar widget to display the user count.

The function does not add any HTML formatting to the user count and simply returns the number. You may want to wrap the shortcode around HTML to use CSS or basic HTML formatting. For example:

<p>Join <strong>[user_count]</strong> other users who share your interests:</p>

Here is how it looked on our demo site:

Showing total number of users in WordPress widget

Note: We also added a free signup button that redirected to a custom WordPress user registration page.

Additional Resources:

That’s all. We hope this article helped you learn how to show the total number of registered users in WordPress. You may also want to see our guide on moderating new user registrations in WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

12 CommentsLeave a Reply

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

      • papoo says

        i found a way
        add shortcode on a page, then access on json with
        wp-json/wp/v2/pages/?slug=”name of the page”
        and… search the info

  2. B says

    Thanks for the manual code!

    Is there any way to display the user count from another WordPress site? I have a public facing website and private “app” that are two different installs and I want to show the app users on the public site.

  3. Chad says

    Hey, thanks for this article, its right along the lines of what I am trying to accomplish. Is there a way to only display the subscribers as opposed to the total number of users? I have been scouring the wp codex site but to no avail. I have found a way to populate a list of subscribers but not jsut a total number of them. This would be extremely handy on the website I am building I would love to hear your insight. Thanks again. :)

    • Matt says

      This might be helpful for you:

      // Function to show the user count by role via shortcode
      function wpb_user_count($atts) {
      $atts = shortcode_atts( array(
      ‘role’ => ”
      ), $atts );
      $user_query = new WP_User_Query( array( ‘role’ => $atts[‘role’] ) );
      // Get the total number of users for the current query. I use (int) only for sanitize.
      $result = (int) $user_query->get_total();
      return $result;
      }
      // Creating a shortcode to display user count
      add_shortcode(‘user_count’, ‘wpb_user_count’);

      // Use this Shortcode to show user [user_count role=”Subscriber”]

  4. Benedikt says

    Hey Guys,
    found this article and tried both options and both do not work. Usually I am pretty good in this WP stuff …

    Could it be that it does not work with certain themes?

    It would be great if you could help:
    Here is the page:
    (We use the Kleo Theme)

    Thanks
    Benedikt

  5. Benedikt says

    Hey Guys,
    found this article and tried both options and both do not work. Usually I am pretty good in this WP stuff …

    It would be great if you could help

    Thanks
    Benedikt

Leave a Reply to Angela Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WPBeginner Assistant
How can I help you?

By chatting, you consent to this chat being stored according to our privacy policy and your email will be added to receive weekly WordPress tutorials from WPBeginner.