In this tutorial, we will learn how to show total number of registered users in WordPress.
Method 1: Show Registered User Count Using a WordPress Plugin
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 Settings » Simple Blog Stats page to configure plugin settings.
This plugin allows you to show different stats from your WordPress site. You need to click on the shortcodes tab to expand it and then scroll down to the ‘number of users’ row.
You will see the shortcode [sbs_users]
with two text fields on both sides. These text fields contain HTML the plugin will add before and after the number of users.
By default, the shortcode will output HTML like this:
856
If you are unsure, then just 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. If the shortcode does not work in the widget, then follow instructions in our guide on how to use shortcodes in your WordPress sidebar widget.
Method 2: Manually Show Number of Registered Users in WordPress with Code
This method requires you to add code to your WordPress site. If you haven’t done this before, then see our beginner’s guide on pasting snippets from web into WordPress.
You need to add the following code to your theme’s functions.php file or a site-specific plugin.
// 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 shortcode [user_count]
which 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:
Join [user_count] other users who share your interest:
Here is how it looked on our demo site:
Note: We added a free signup button that redirected to a custom WordPress user registration page.
That’s all, we hope this tutorial helped you learn how to show the total number of registered users in WordPress.