Title: wp_maybe_update_user_counts
Published: May 25, 2022
Last modified: February 24, 2026

---

# wp_maybe_update_user_counts( int|null $network_id = null ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#wp--skip-link--target)

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#parameters)󠁿

 `$network_id`int|nulloptional

ID of the network. Defaults to the current network.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#return)󠁿

 bool Whether the update was successful.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#source)󠁿

    ```php
    function wp_maybe_update_user_counts( $network_id = null ) {
    	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'
    		);
    	}

    	$is_small_network = ! wp_is_large_user_count( $network_id );
    	/** This filter is documented in wp-includes/ms-functions.php */
    	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) {
    		return false;
    	}

    	return wp_update_user_counts( $network_id );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/user.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/user.php#L1485)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/user.php#L1485-L1505)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#hooks)󠁿

 [apply_filters( ‘enable_live_network_counts’, bool $small_network, string $context )](https://developer.wordpress.org/reference/hooks/enable_live_network_counts/)

Filters whether to update network site or user counts when a new site is created.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_is_large_user_count()](https://developer.wordpress.org/reference/functions/wp_is_large_user_count/)`wp-includes/user.php` |

Determines whether the site has a large number of users.

  | 
| [wp_update_user_counts()](https://developer.wordpress.org/reference/functions/wp_update_user_counts/)`wp-includes/user.php` |

Updates the total count of users on the site.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [is_multisite()](https://developer.wordpress.org/reference/functions/is_multisite/)`wp-includes/load.php` |

Determines whether Multisite is enabled.

  | 
| [_doing_it_wrong()](https://developer.wordpress.org/reference/functions/_doing_it_wrong/)`wp-includes/functions.php` |

Marks something as being incorrectly called.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 4 more](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_maybe_update_user_counts/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.0.0](https://developer.wordpress.org/reference/since/6.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_maybe_update_user_counts%2F)
before being able to contribute a note or feedback.