函数原型
get_user_count( int|null $network_id = null ): int
函数描述
Returns the number of active users in your installation.
是否弃用
未弃用
函数参数
-
$network_id
int|null
Optional - ID of the network. Defaults to the current network.
Default:
null
函数返回值
int Number of active users on the network.
函数位置
File: wp-includes/user.php.
函数源码
function get_user_count( $network_id = null ) {
if ( ! is_multisite() && null !== $network_id ) {
_doing_it_wrong(
__FUNCTION__,
sprintf(
/* translators: %s: $network_id */
__( 'Unable to pass %s if not using multisite.' ),
'<code>$network_id</code>'
),
'6.0.0'
);
}
return (int) get_network_option( $network_id, 'user_count', -1 );
}
源码链接
变更日志
| Version | Description |
|---|---|
| MU (3.0.0) | MU (3.0.0) |
| 6.0.0 | Moved to wp-includes/user.php. |
| 4.8.0 | Introduced. |

