Title: get_user_count
Published: April 25, 2014
Last modified: February 24, 2026

---

# get_user_count( int|null $network_id = null ): int

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/get_user_count/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/get_user_count/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_user_count/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_user_count/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/get_user_count/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_user_count/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/get_user_count/?output_format=md#user-contributed-notes)

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

Returns the number of active users in your installation.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/get_user_count/?output_format=md#description)󠁿

Note that on a large site the count may be cached and only updated twice daily.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_user_count/?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/get_user_count/?output_format=md#return)󠁿

 int Number of active users on the network.

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

    ```php
    function get_user_count( $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'
    		);
    	}

    	return (int) get_network_option( $network_id, 'user_count', -1 );
    }
    ```

[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#L1461)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/user.php#L1461-L1475)

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

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

Retrieves a network’s option value based on the option name.

  | 
| [__()](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.

  |

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

| Used by | Description | 
| [WP_Debug_Data::get_wp_core()](https://developer.wordpress.org/reference/classes/wp_debug_data/get_wp_core/)`wp-admin/includes/class-wp-debug-data.php` |

Gets the WordPress core section of the debug data.

  | 
| [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_MS_Users_List_Table::get_views()](https://developer.wordpress.org/reference/classes/wp_ms_users_list_table/get_views/)`wp-admin/includes/class-wp-ms-users-list-table.php` |  | 
| [wp_network_dashboard_right_now()](https://developer.wordpress.org/reference/functions/wp_network_dashboard_right_now/)`wp-admin/includes/dashboard.php` |  | 
| [wp_version_check()](https://developer.wordpress.org/reference/functions/wp_version_check/)`wp-includes/update.php` |

Checks WordPress version against the newest version.

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

Determines whether or not we have a large network.

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

Gets the network’s site and user counts.

  |

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

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

| Version | Description | 
| [MU (3.0.0)](https://developer.wordpress.org/reference/since/mu.3.0.0/) | MU (3.0.0) | 
| [6.0.0](https://developer.wordpress.org/reference/since/6.0.0/) | Moved to wp-includes/user.php. | 
| [4.8.0](https://developer.wordpress.org/reference/since/4.8.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/get_user_count/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/functions/get_user_count/?output_format=md#comment-content-2281)
 2.    [Rami Yushuvaev](https://profiles.wordpress.org/ramiy/)  [  9 years ago  ](https://developer.wordpress.org/reference/functions/get_user_count/#comment-2281)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_user_count%2F%23comment-2281)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_user_count%2F%23comment-2281)
 4.      ```php
         printf(
         	/* translators: %s: User count */
         	__( 'There are currently %s users on this site.', 'text-domain' ),
         	get_user_count()
         );
         ```
     
 5.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_user_count%2F%3Freplytocom%3D2281%23feedback-editor-2281)
 6.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/get_user_count/?output_format=md#comment-content-1522)
 7.    [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/get_user_count/#comment-1522)
 8.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_user_count%2F%23comment-1522)
     Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_user_count%2F%23comment-1522)
 9.  **Get number of active users**
 10.     ```php
         $user_count = get_user_count();
         echo "There are currently $user_count users on this site.";
         ```
     
 11.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_user_count%2F%3Freplytocom%3D1522%23feedback-editor-1522)

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