get_user_count

The timeline below displays how wordpress function get_user_count has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Returns the number of active users in your installation.
 *
 * Note that on a large site the count may be cached and only updated twice daily.
 *
 * @since MU (3.0.0)
 * @since 4.8.0 The `$network_id` parameter has been added.
 * @since 6.0.0 Moved to wp-includes/user.php.
 *
 * @param int|null $network_id ID of the network. Defaults to the current network.
 * @return int Number of active users on the network.
 */
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);
}

WordPress Version: 5.1

/**
 * The number of active users in your installation.
 *
 * The count is cached and updated twice daily. This is not a live count.
 *
 * @since MU (3.0.0)
 * @since 4.8.0 The `$network_id` parameter has been added.
 *
 * @param int|null $network_id ID of the network. Default is the current network.
 * @return int Number of active users on the network.
 */
function get_user_count($network_id = null)
{
    return get_network_option($network_id, 'user_count');
}

WordPress Version: 4.9

/**
 * The number of active users in your installation.
 *
 * The count is cached and updated twice daily. This is not a live count.
 *
 * @since MU (3.0.0)
 * @since 4.8.0 The $network_id parameter has been added.
 *
 * @param int|null $network_id ID of the network. Default is the current network.
 * @return int Number of active users on the network.
 */
function get_user_count($network_id = null)
{
    return get_network_option($network_id, 'user_count');
}

WordPress Version: 4.8

/**
 * The number of active users in your installation.
 *
 * The count is cached and updated twice daily. This is not a live count.
 *
 * @since MU 2.7
 * @since 4.8.0 The $network_id parameter has been added.
 *
 * @param int|null $network_id ID of the network. Default is the current network.
 * @return int Number of active users on the network.
 */
function get_user_count($network_id = null)
{
    return get_network_option($network_id, 'user_count');
}

WordPress Version: 3.7

/**
 * The number of active users in your installation.
 *
 * The count is cached and updated twice daily. This is not a live count.
 *
 * @since MU 2.7
 *
 * @return int
 */
function get_user_count()
{
    return get_site_option('user_count');
}