WordPress Multisite – When a user signs-up on main site, how to add the user to a subsite

I am setting up a WordPress multisite network, where users may subscribe to one or more services on the main site and may have access to content on subsite. The access on subsite will depend on the service they subscribe on the main site.

What I want to do using some code is when a user registers on main site, I can add that user to the subsite and add some attribute/meta-data to define what access the user has on the subsite (may be I will use memberpress to manage the access)

My main question is what code can be used to add a user to subsite when he signs up main site?

2 s
2

Run add_user_to_blog() after user creation.

You can hook on user_register() to get newly created user ID and pass it and any conditional assignments to your callback that runs add_user_to_blog().

Leave a Comment