pre_count_users filter-hookWP 5.1.0

Filters the user count before queries are run.

Return a non-null value to cause count_users() to return early.

Usage

add_filter( 'pre_count_users', 'wp_kama_pre_count_users_filter', 10, 3 );

/**
 * Function for `pre_count_users` filter-hook.
 * 
 * @param null|array $result   The value to return instead.
 * @param string     $strategy Optional. The computational strategy to use when counting the users. Accepts either 'time' or 'memory'.
 * @param int        $site_id  The site ID to count users for.
 *
 * @return null|array
 */
function wp_kama_pre_count_users_filter( $result, $strategy, $site_id ){

	// filter...
	return $result;
}
$result(null|array)
The value to return instead.
Default: null to continue with the query
$strategy(string)
Optional. The computational strategy to use when counting the users. Accepts either 'time' or 'memory'.
Default: 'time'
$site_id(int)
The site ID to count users for.

Changelog

Since 5.1.0 Introduced.

Where the hook is called

count_users()
pre_count_users
wp-includes/user.php 1246
$pre = apply_filters( 'pre_count_users', null, $strategy, $site_id );

Where the hook is used in WordPress

Usage not found.