On this page
get_user_count( int|null $network_id = null ): int
Returns the number of active users in your installation.
Description
Note that on a large site the count may be cached and only updated twice daily.
Parameters
$network_idint|null Optional-
ID of the network. Defaults to the current network.
Default:
null
Return
int Number of active users on the network.
Source
File: wp-includes/user.php. View all references
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 );
}
Related
Uses
| Uses | Description |
|---|---|
| get_network_option() wp-includes/option.php | Retrieves a network’s option value based on the option name. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| is_multisite() wp-includes/load.php | If Multisite is enabled. |
| _doing_it_wrong() wp-includes/functions.php | Marks something as being incorrectly called. |
Used By
| Used By | Description |
|---|---|
| wp_is_large_user_count() wp-includes/user.php | Determines whether the site has a large number of users. |
| WP_Debug_Data::debug_data() wp-admin/includes/class-wp-debug-data.php | Static function for generating site debug data when required. |
| WP_MS_Users_List_Table::get_views() wp-admin/includes/class-wp-ms-users-list-table.php | |
| wp_network_dashboard_right_now() wp-admin/includes/dashboard.php | |
| wp_version_check() wp-includes/update.php | Checks WordPress version against the newest version. |
| wp_is_large_network() wp-includes/ms-functions.php | Determines whether or not we have a large network. |
| get_sitestats() wp-includes/ms-functions.php | Gets the network’s site and user counts. |
Changelog
| Version | Description |
|---|---|
| MU (3.0.0) | MU (3.0.0) |
| 6.0.0 | Moved to wp-includes/user.php. |
| 4.8.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_user_count