You can hook to wpmu_activate_user
and add the user’s role on the main site.
add_action( 'wpmu_activate_user', 'wpse363445_add_user_to_main_site' );
function wpse363445_add_user_to_main_site( $user_id ) {
if ( is_main_site() ) {
// Don't run if we're already on the main site.
return;
}
if ( is_user_member_of_blog( get_main_site_id(), $user_id ) ) {
// Don't add the user to the main site if they're already a member.
return;
}
add_user_to_blog( get_main_site_id(), $user_id, 'subscriber' );
}
References
wpmu_activate_user
hookis_main_site()
add_user_to_blog()
get_main_site_id()
is_user_member_of_blog()
Note: This will only work for users that get sent an activation email. If you manually add a user to a site, and opt to not send them an activation email, you’ll need to add them to the main site manually.
Related Posts:
- How can I un-reserve a pending username registration?
- wordpress multisite, how to keep user on subdomain throughout registration process?
- Allowing periods in usernames
- Remove Site Name from register form – Multisite
- Prevent user creating new users with specific roles
- Get first_name and last_name on user_register hook
- Can’t add user to blog on registration (Multisite)
- Is there a wordpress function to cleanly delete an entry in the signups table?
- WordPress 3.2(Multisite) – How to add custom user meta fields to signup form?
- How to add multiple existing users to a multisite site?
- WPMU – new users are automatically subscribed to the main blog – how to prevent that?
- User registration on sub site
- Disable domain redirect
- Displaying a message upon user registration
- What sites are you registered to when joining a multisite?
- Add a user to a specific blog when they register?
- Auto creation of multisite blog on user registration
- Multisite – user email activation links broken
- Add menu items/actions for multisite users who are registered on the network but do not have a role or capability in any sites
- Four columns in the wp_users table
- WP MU Register User across all blogs
- Is the Multi site functionality a viable option for Country and Language targeting?
- Using the standard WordPress “New User” interface on a multisite
- How can you override the is_multisite check in wp-login.php for individual login/registration?
- User registration on two sites in same multisite
- How to change a user role after registering in multisite?
- How to fix that new users show up again in subsite of a Multisite?
- User registration is currently not allowed
- Multisite ‘Welcome User Email’ SITE_NAME returns ‘network’ name, not the name of the blog
- User registration on wordpress multisite
- Easily adding multiple existing users to a multisite site
- Register a user only to the root blog – WP Multisite
- Activate User account for Sub Site broken
- Possible to have duplicate usernames on different two multisites
- How to allow mixed case characters in multisite site name?
- Modify new user email notification in network admin screen wp multisite
- Users getting linked unwanted to main mu in WordPress multisite (WPMU)
- Can’t activate a user on multisite install
- WordPress Multisite Network Subdomain
- Multisite: How to bypass wpmu_signup_user_notification and add my own notification logic?
- Allow users to register on multisite through WooCommerce using the same email address
- A different role for each site in a multisite
- Activation of new Registered site fails on multisite
- User registration problem on multisites web
- Multisite “Skip Confirmation Email” Log Out Problem
- Multisite – User creation for second site from first site?
- How to Create WPMu New User?
- Possible to set new user’s site time zone at user creation using Gravity Forms?
- multisite registration: check existing subdomains while typing
- Registration Page
- Using a number for limiting registering or banning on multisite
- How to use same email for multiple users? [duplicate]
- How to disable a network enabled plugin for just one site?
- Plugin for editing options on multisite?
- Set default avatar network-wide
- wp-activate.php causing white screen of death
- Multisite: Develop locally using production images with .htaccess
- How to prevent hotlinking with htaccess in WordPress and why most common use about it doesn’t work?
- How do I set a default theme in multisite network
- Multisite use language code as subdirectory
- How to remove the Tools menu item from the WP-Admin menu
- Using $wpdb Class to Pull Recent Comments Across a Network
- WordPress (+WPMU) Import/Export ALL settings?
- How do you load WordPress from an external script when using MultiSite? [duplicate]
- Has WP and MU fully merged?
- Migrate a WP website from a single-server single-domain to a multi-server multi-domain installation
- current_user_can() always returns true if user is super admin
- multisite hook for Add Existing User
- access the plugins for each role in WordPress multisite
- ReWriteRules and WordPress Multi-Sites with Sub Directories
- WordPress: how to change URL for individual MultiSites?
- Change main site in multisite install?
- Enable “My blogs” in a custom installation
- HTTPS Warning and Certificate Error when Updating Network
- Complex WordPress Website
- Where to set individual blog quotas?
- Create sub-domain for multisite and multi languages?
- How to retrieve Post Excerpt from a different site in the Network
- how to have __() translating in languages different from admin?
- How to temporarily redirect front page of a network to one of the sites/blogs?
- Multisite: Redirect to appropriate domain if subdomain doesn’t exist
- Multisite questions
- Delete user from multisite when removed from subsite
- how to control display switch_to_blog( $subsite->blog_id ); $tags = wp_tag_cloud
- WordPress multisite with domains and subdomains
- Multisite 404 page
- Sort posts according to date
- the_content not working on one of two Multisite sites
- How can I have two or more WordPress Pro (paid) themes that form a single website?
- On a multisite environment, get the subdomain value as variable
- After switch domain, some parts of my site still point to my old domain
- How To Change the URL of a WordPress Multisite
- Site w/ Addon Domain doesn’t show CSS
- WordPress MU – Creating a site takes ages
- Default sub-pages on WordPress Multisite
- WordPress Multisite – Questions about select all posts from all network sites
- Multi site and media uploader
- Comment reporting for Multisite
- How to display the most popular posts of all the blogs in a mu setup? [duplicate]
- Subdomain add comment redirect to 404 not found page iis server