Anyone 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 );