WordPress | count_users Function

Prem Tiwari - - WordPress Functions


The count_users() function will count the number of users who have each of the user roles in your WordPress.

Below is the syntax of count_users () Function, how to use in your WordPress plugin or theme file.

Syntax:

Used Parameters:

$strategy :(string) (Optional) The computational strategy to use when counting the users. Accepts either ‘time’ or ‘memory’. Default value: ‘time’

$site_id : (int|null) (Optional) The site ID to count users for. Defaults to the current site. Default value: null

Below is an exaple of count_user() funtion hot to use in your code.


About: Prem Tiwari

Prem Tiwari is the founder of FreeWebMentor.com and also a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies.