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|string $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|null    $site_id  Optional. The site ID to count users for.
 *
 * @return null|string
 */
function wp_kama_pre_count_users_filter( $result, $strategy, $site_id ){

	// filter...
	return $result;
}
$result(null|string)
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|null)
Optional. The site ID to count users for.
Default: current site

Changelog

Since 5.1.0 Introduced.

Where the hook is called

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

Where the hook is used in WordPress

Usage not found.