wp_update_user_counts() WordPress Function
The wp_update_user_counts() function updates the user counts for the current site. This function is called whenever a user is added or removed from the site.
wp_update_user_counts( int|null $network_id = null ) #
Updates the total count of users on the site.
Parameters
- $network_id
(int|null)(Optional)ID of the network. Defaults to the current network.
Default value: null
Return
(bool) Whether the update was successful.
Source
File: wp-includes/user.php
function wp_update_user_counts( $network_id = null ) { global $wpdb; 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' ); } $query = "SELECT COUNT(ID) as c FROM $wpdb->users"; if ( is_multisite() ) { $query .= " WHERE spam = '0' AND deleted = '0'"; } $count = $wpdb->get_var( $query ); return update_network_option( $network_id, 'user_count', $count ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
6.0.0 | Introduced. |