Skip Navigation

[Resuelto] user Registration form for multiple role

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:
How to allow users to choose their role in a user registration form?

Solution:
There is no option to include a role selector in such a form, but you can add a generic select field to the form where the role option is chosen, and then use the cred_save_data hook to run some code that updates the role after the form has been submitted and the user created.

An example is given in this linked thread: https://toolset.com/forums/topic/radio-buttons-selection-triggers-assigning-to-one-of-2-user-roles/

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

This support ticket is created hace 6 años, 2 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Este tema contiene 4 respuestas, tiene 2 mensajes.

Última actualización por Akhil hace 6 años, 2 meses.

Asistido por: Nigel.

Autor
Mensajes
#1113880

Hi.

i realize toolset form allow register one user type only.

my case i have 5 user role [same fields,] that using same form. is that achievable in toolset ?

If yes pls guide. thank you.

#1114269

Nigel
Supporter

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00:00)

You want one registration form to allow people to register with one of five different roles, is that right?

As you will have seen for yourself, when you create a registration form the form settings specify the role of the user that will be created by the form.

If you want to register users with different roles the expectation is that you create different forms for each role, and insert each of them on their own page, or on the same page and use conditional shortcodes to determine which to show according to some criteria.

As a shortcut when creating multiple similar forms you can clone existing forms and then make minor edits (e.g. to the role of the created user).

If you wanted to use a single form then you would need to use the API, e.g. the cred_save_data hook, and then modify the role using the set_role method of the WP_User class. I don't know how you would intend such a form to know which role to set?

#1114353

HI nigel., the roles are basically same its just renamed to keep track the source login.
example

user_fb, user_linkedin etc. all come under main role " suscriber" .
I understand the part to close and add custom condition, but thats not needed for my case.
for simplicity i would need one form that able to register by 5 other roles.

appreciate if you have sample code for this for me to kickstart. Thanks.

#1114987

Nigel
Supporter

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00:00)

You can find an example of setting the role after the form has been submitted in this thread: https://toolset.com/forums/topic/radio-buttons-selection-triggers-assigning-to-one-of-2-user-roles/

In that example the form includes a dropdown where the desired role is selected. It sounds like you will use something something else to determine the role, but the principles should be clear from the example code in that thread.

Let me know if you get stuck.

#1115699

My issue is resolved now. Thank you!