# Showing registered users on WordPress using PHP

> Display the total number of registered users on your WordPress site with a simple PHP function and shortcode.

Source: https://helpcenter.ruachost.com/wordpress/guides/showing-registered-users-on-wordpress-using-php/

WordPress stores all registered users in its database. You can display the **total number of registered users** on your site using a simple PHP function. On **ruachost.com**, this is often used to highlight site popularity or community size.

## Why Show Registered Users?

- Demonstrates site growth and credibility.
- Encourages new visitors to register.
- Useful for membership sites, forums, or communities.

## Steps to Display Registered Users

1. **Log in to WordPress** with an administrator account.
2. In the dashboard, go to **Appearance → Theme Editor**.
3. From the right‑hand column, select the file named **functions.php**.
4. Scroll to the bottom of the file and add the following code:

   ```
   // Function to return user count
   function wpb_user_count() {
       $usercount = count_users();
       $result = $usercount['total_users'];
       return $result;
   }

   // Creating a shortcode to display user count
   add_shortcode('user_count', 'wpb_user_count');
   ```
5. Click **Update File** to save changes.

## ⚙️ Using the Shortcode

- To display the total number of registered users anywhere on your site, type:

  ```
  [user_count]
  ```

✅ WordPress will automatically replace `[user_count]` with the total number of registered users.

## Important Notes

- Always back up your site before editing theme files.
- Consider using a **child theme** to preserve changes during updates.
- This shortcode works in posts, pages, and widgets.
