Code to Show Total Number of Registered Users in WordPress

/* Create Function to Call User Count */
function wpflt_reg_user_count() { 
$usercount = count_users();
$result = $usercount['total_users']; 
return $result; 
} 
/* Create ShortCode */
add_shortcode('reg_user_count', 'wpflt_reg_user_count');

If you want to show the total number of registered users in the front end, add the above code to your theme functions. If you are running a Membership Site or WooCommerce store, you can utilize this code to gain trust of new visitors so that you convert them as your customers or members.

Above function creates a ShortCode ‘reg_user_count‘ which can be called anywhere on the page to display the total number of registered users in WordPress. ShortCode must be enclosed with Square Brackets, like this [reg_user_count].

To Display the User Count in the Front End add the below Custom HTML Block anywhere you like. It can be Page, Post, Sidebar, Header, Footer, etc. Modify according to your preference.

<p class="registered-user-count"><a href="https://example.com/register/">Register</a> as a Member and Enjoy just like <span>[reg_user_count]</span> others in this Club</p>

We have added the class, ‘registered-user-count‘ enclosing the ShortCode with text content. You can use the below CSS for customize the Display Box.

/* CSS for the Custom HTML Display Box */
.registered-user-count {
    background: black;
    padding: 10px;
    margin: 10px;
    color: white;
}
/* CSS for Anchor Text */
.registered-user-count a {
    color: lime !important;
    text-transform: uppercase;
}
/* User Count CSS */
.registered-user-count span {
    font-size: 25px;
    opacity: 50%;
    color: white;
    background: red;
    padding-right: 8px;
    padding-left: 8px;
}

PS: Depending on the Theme, if the ShortCode isn’t getting executed in the front end inside sidebar text widget, use the below filter in your theme functions. A theme like GeneratePress allows Sidebar ShortCode execution in both Text and Custom HTML Widgets.

/* Enable ShortCodes in Text Widgets */
add_filter('widget_text','do_shortcode');
/* Use only if Necessary */