首页 WordPress函数大全 count_users()

count_users()

2020-05-01 / 3644阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

count_users( string $strategy = 'time', int|null $site_id = null )

Count number of users who have each of the user roles.

描述

Assumes there are neither duplicated nor orphaned capabilities meta_values. Assumes role names are unique phrases. Same assumption made by WP_User_Query::prepare_query() Using $strategy = ‘time’ this is CPU-intensive and should handle around 10^7 users. Using $strategy = ‘memory’ this is memory-intensive and should handle around 10^5 users, but see WP Bug #12257.

参数

$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

返回

(array) User counts.

  • 'total_users'
    (int) Total number of users on the site.
  • 'avail_roles'
    (int[]) Array of user counts keyed by user role.
大家谈论
    我的见解