This project is read-only.

Different User Types in Orchard

Topics: Writing modules
Nov 13, 2013 at 11:00 PM

I'm trying to figure out what would be best way to have different user types in Orchard.

One option is create different content types for different user types. To do this, different user types should have different content parts keeping their profile, in addition to UserPart.

partner user -> user part + user roles part + partner part
customer user -> user part + user roles part + partner part

In this case, we would have three user types, these ones and the regular User created by Orchard.Users module.

In fact, Orchard itself doesn't attach UserPart and UserRolesPart to User content type, but hooks an activating filter to provide these parts. I guess this is to allow suppressing the default by different implementations. I couldn't find anything else attached to User this way, but I might be missing something.

Another option is to attach a custom part to User content type, assign an enum value to a property of this part to store the user type.

user -> user part + user roles part + custom part that keeps the user type

That custom part can also have lazy fields pointing to some records of profile info for different user types, or forget about normalization and keep all the data any type of users would need.

In this case there will be only one user content type, handling different user types. Not as flexible as the first option, but look more managable to me. On the other hand this might be me talking from the developer point of view, not the end user.

Yet another option would be to attach no part to User content type, differentiate between users using custom permissions, keep the profile data in non-content records and manage them using controllers/widgets. This sounds like a total denial of "user as content"

Now, I'd like to know about your experiences with any of these, or some other ways you can think of. Any best practices?

Nov 13, 2013 at 11:52 PM
I'd go for the second option myself, but both should work.