How is Orchard.Roles attached to Orchard.Users?

Topics: Customizing Orchard, General
Aug 10, 2011 at 11:26 PM

I am having trouble seeing how the roles module gets attached to users. I would like to be able to modify the user create/edit process so that as well as selecting roles for the user, the administrator can select some extra settings (defined in a module I created). I assumed this would be as easy as hooking into the Users module the same way as Roles does, but I can't see how that is actually joined up.

I've been looking through the code but still can't see how this occurs, any help would be great. Is this what "welding" is about?

Cheers

Coordinator
Aug 10, 2011 at 11:40 PM

It's because they are very weakly coupled, so that roles can be removed easily. It's the UserRolesPart that is making the connection, from the Roles side.

Aug 10, 2011 at 11:50 PM

Thanks for the fast reply Bertrand. I've had a look deeper, is it the line 

Filters.Add(new ActivatingFilter<UserRolesPart>("User"));

in Orchard.Roles/Handlers/UserRolesPartHandler.cs that is doing the coupling? (that's what I am assuming based on the intellisense).

Aug 10, 2011 at 11:55 PM

Awesome, I think I was correct, I just added that line to one of my part handlers and on the user screen I now get the edit form for that part. I'll update this again once I have this working with a detailed how-to.