Different Profile per user role

How to create different profiles for different user roles
for example, i have the following roles:

  • patient
  • doctor

i need to assign different profiles (with different fields) to each role

any help on how to do this please ?

You can achieve this with Dynamic Zone & Compoments.

Create a dynamic zone in User’s Model: User Profile
Create two components: patient, doctor.

For each component add its own fields.

Now add these two components in to the User Profile dynamic zone.

1 Like

in this case, it is possible to add multiple profiles for the user . i need to limit it to 1 profile per user

perfect … it worked, just needed to limit the number of maximum values to 1… THANKS

1 Like

is there a way to have conditional field in user model based on the selected role / ? so there is no chance to select a doctor profile for a patient role

Unfortunately no, currently you can’t achieve this inside Strapi’s admin. Only by modifying the core files, which I would not recommend you to do.

You will have a Frontend for administration or you will use only Strapi admin?

super-admin uses strapi admin. and it will be used by non-teck people, who can do such mistakes

You can limit the update of user inside beforeUpdate lifecycle, by checking current role and the dynamic zone, if these are different then do not update user and throw an error.

thats a good idea. it will work as a work around until having a solution to not even give the option to the admin to select wrong entry. (keep in mind that the client is not tech and they will start too much bla bla talk about gettng errors and warnings :sweat_smile:)