Filter hook 'enable_live_network_counts'

in WP Core File wp-includes/user.php at line 1487

View Source

enable_live_network_counts

Filter Hook
Description
Updates the total count of users on the site if live user counting is enabled.

Hook Information

File Location wp-includes/user.php View on GitHub
Hook Type Filter
Line Number 1487

Hook Parameters

Type Name Description
int|null $network_id ID of the network. Defaults to the current network.

Usage Examples

Basic Usage
<?php
// Hook into enable_live_network_counts
add_filter('enable_live_network_counts', 'my_custom_filter', 10, 1);

function my_custom_filter($network_id) {
    // Your custom filtering logic here
    return $network_id;
}

Source Code Context

wp-includes/user.php:1487 - How this hook is used in WordPress core
<?php
1482  		);
1483  	}
1484  
1485  	$is_small_network = ! wp_is_large_user_count( $network_id );
1486  	/** This filter is documented in wp-includes/ms-functions.php */
1487  	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) {
1488  		return false;
1489  	}
1490  
1491  	return wp_update_user_counts( $network_id );
1492  }

PHP Documentation

<?php
/**
 * Updates the total count of users on the site if live user counting is enabled.
 *
 * @since 6.0.0
 *
 * @param int|null $network_id ID of the network. Defaults to the current network.
 * @return bool Whether the update was successful.
 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/user.php
Related Hooks

Related hooks will be displayed here in future updates.