# Add New Network Users to the Main Site

> Adds every newly registered user to the main site with a role you choose, so members of any subsite also have an account on your hub site.

- Type: PHP
- Runs: Run everywhere
- Category: [Multisite](https://wpide.com/library/category/multisite/)
- Tags: users, registration, main-site
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/ms-add-new-users-to-main-site/

## Code

```php
if ( ! is_multisite() ) {
    return;
}

$wpide_role = 'subscriber'; // Role on the main site.

$wpide_add = function ( $user_id ) use ( $wpide_role ) {
    $main = get_main_site_id();

    if ( ! is_user_member_of_blog( $user_id, $main ) ) {
        add_user_to_blog( $main, $user_id, $wpide_role );
    }
};

add_action( 'wpmu_new_user', $wpide_add );
add_action( 'wpmu_activate_user', $wpide_add );
```

## Notes

Change $wpide_role. Users who are already members of the main site are left alone.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Add New Network Users to the Main Site" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
