XF 2.2 Custom User Field required depending on previous selection

Joan1211

Member
Hello,

I am looking to do this:
When a user registers, he has to select a group (that i created with Custom User Field).
However for a specific group I need the user to enter a registration code that i will provide him.

Is there a way that selecting a specific user group during registration, makes the other custom user field required?

1) If the user selects group 1,2 or 4, the code is not required.
2) If the user selects group 3, the code is required.

Thank you.


Screenshot 2023-07-01 at 16.26.18 copy 3.webp
 
Last edited:
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.
 
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.


Screenshot 2023-07-01 at 17.27.57.png


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.
 
Last edited:
Top Bottom