Skip Navigation

[Resolved] Separate user registration on Multisite Network

This thread is resolved. Here is a description of the problem and solution.

Problem:

I'm using a toolset user cred form on a multisite installation of WordPress. If users only have an account on one subsite, the registration works. However, if users are registered on one subsite, they aren't currently able to register on a subsite. Instead, they get an 'that email already exists' and 'that username already exists' error and an administrator has to give them access to the subsite. I would like to give users the ability to register for each site, without requiring approval from an administrator.

Solution:

Toolset register user form is for creating new users, you can not create two users with the same email address, so you will get those error message:

'that email already exists' and 'that username already exists'

You might consider custom codes, for example:

https://toolset.com/forums/topic/separate-user-registration-on-multisite-network/#post-1557013

Relevant Documentation:

This support ticket is created 4 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by erinJ 4 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1556765

Tell us what you are trying to do?

I'm using a toolset user cred form on a multisite installation of WordPress. If users only have an account on one subsite, the registration works. However, if users are registered on one subsite, they aren't currently able to register on a subsite. Instead, they get an 'that email already exists' and 'that username already exists' error and an administrator has to give them access to the subsite. I would like to give users the ability to register for each site, without requiring approval from an administrator.

I have installed a third-party plugin (https://wordpress.org/plugins/network-subsite-user-registration/) but this doesn't seem to be compatible with CRED user registration.

Is there a hook or function I can use to avoid these errors and auto-add users with existing network accounts to the subsites?

What is the link to your site?

main site: hidden link
subsite: hidden link

#1557013

Hello,

This is expected result, in WordPress multisite installation, there is only one database table "wp_users", it stores the list of all users of all sub sites, and the user's email should be unique.

Toolset register user form is for creating new users, you can not create two users with the same email address, so you will get those error message:
'that email already exists' and 'that username already exists'

For the question:
Is there a hook or function I can use to avoid these errors and auto-add users with existing network accounts to the subsites?
You might consider custom codes, for example, the filter hook "cred_form_validate", see our document:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate
This hook provides custom validation for form fields.

For example, when user submit the user register form, use above filter hook "cred_form_validate" to trigger a PHP function, in this PHP function, do these:
1) Check if the new user email/user name existed, then get the user's ID
https://developer.wordpress.org/reference/functions/get_users/
2) Check if above user ID is a member of current sub site:
https://developer.wordpress.org/reference/functions/is_user_member_of_blog/
3) If it isn't a member, add the user as subsite member,
https://codex.wordpress.org/Function_Reference/add_user_to_blog
and return an error message: You are added as a member

#1557745

Thanks. I will give this a try!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.