The one weakness I see with your scenario.. what's to keep them from picking (when signing up) groups 1,2 or 4.
Honestly... if this is important for the site... you many want to inquire into a bespoke add-on.
By default... XF will not "show" another custom field based upon what one selects prior.
Groups 1, 2, and 4 have company emails, while Group 3 does not.
When a user registers, they are automatically assigned to the Register group. This group has very restrictive permissions, with most nodes disabled.
The permissions for groups 1, 2, 3, and 4 vary, depending on each group.
I have created a User Group Promotion that promotes users to groups 1, 2, and 4 if they select those groups and have an email ending with "@mycompany.com".
However, since Group 3 does not have an email, I am struggling to find a solution to give them access to the forum.
The solution I have found is to create another Custom User Field. I created a User Group Promotion that promotes users to Group 3
IF they select Group 3
AND enter the corresponding regular expression code.
To answer your question, if a user selects groups 1, 2, or 4 without a company email, they will not be able to access the forum.
The problem I am facing is that I would like to regularly change the code. However, if I change the code, when the cron job runs, it will demote users in Group 3 because their code in their profile will not match the new one.
Currently, I have found a solution by creating a clone of Group 3 called "Group 3 - Validated Users." When a user selects Group 3 and enters a code, they are promoted to Group 3. Then the admin can manually promote these users to "Group 3 - Validated Members."
When the code is changed, users will be demoted from group 3, but it doesn't matter since they are also part of Group 3 - Validated Members.
However, I am trying to avoid manual interaction. The easiest way would be for the User Group Promotion to promote users to Group 3
IF that group is selected (without requiring a code).
Therefore, I need to make the code mandatory when a user selects Group 3 and not mandatory when any other group is selected.
I hope this clarification makes sense.