pre_count_users
Filter HookDescription
Filters the user count before queries are run. Return a non-null value to cause count_users() to return early.Hook Information
File Location |
wp-includes/user.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1344 |
Hook Parameters
Type | Name | Description |
---|---|---|
null|array
|
$result
|
The value to return instead. Default null to continue with the query. |
string
|
$strategy
|
Optional. The computational strategy to use when counting the users. Accepts either 'time' or 'memory'. Default 'time'. |
int
|
$site_id
|
The site ID to count users for. |
Usage Examples
Basic Usage
<?php
// Hook into pre_count_users
add_filter('pre_count_users', 'my_custom_filter', 10, 3);
function my_custom_filter($result, $strategy, $site_id) {
// Your custom filtering logic here
return $result;
}
Source Code Context
wp-includes/user.php:1344
- How this hook is used in WordPress core
<?php
1339 * @param null|array $result The value to return instead. Default null to continue with the query.
1340 * @param string $strategy Optional. The computational strategy to use when counting the users.
1341 * Accepts either 'time' or 'memory'. Default 'time'.
1342 * @param int $site_id The site ID to count users for.
1343 */
1344 $pre = apply_filters( 'pre_count_users', null, $strategy, $site_id );
1345
1346 if ( null !== $pre ) {
1347 return $pre;
1348 }
1349
PHP Documentation
<?php
/**
* Filters the user count before queries are run.
*
* Return a non-null value to cause count_users() to return early.
*
* @since 5.1.0
*
* @param null|array $result The value to return instead. Default null to continue with the query.
* @param string $strategy Optional. The computational strategy to use when counting the users.
* Accepts either 'time' or 'memory'. Default 'time'.
* @param int $site_id The site ID to count users for.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/user.php
Related Hooks
Related hooks will be displayed here in future updates.