Different fields for different user types

System Information
  • Strapi Version: 4.4.5
  • Operating System: Linux
  • Database: MariaDB
  • Node Version: N/A
  • NPM Version: N/A
  • Yarn Version: N/A

Hello Everyone!

I have a question and I don’t seem to be able to find anything related to this on the forum.

The app I’m working on will have two types of users - students and teachers. Each of these types will have common fields like “name”, “surname” etc. as well as type-specific fields. For example, a teacher will be able to add a video introducing themselves while a student won’t.

How do I approach this and add type-specific fields to each of the user types?

Thank you in advance for your help.

I have a similar thing on a private project I’m doing. I have “books” and “films”, which share a lot of attributes but also have some distinct ones. In typescript I could express this via inheritance, but I think in Strapi this is not possible.

So, in your example, I’d imagine you have two completely separate collection types, one for “student” and one for “teacher”, which have some attributes in common and also some not.

Is it how you solved it?

I’ve been thinking of using dynamic zones.

Or similarly to what you said - I’d keep User as a collection type. Then add two collections: coaches and members. And within User create a relation to one of the other collection entries.

Is it how you solved it?

Yes

I’ve been thinking of using dynamic zones.

Me too, but IMO it comes with to many inconveniences (e.g. population) and opens doors for misuse.