Customizing User Profile page

Topics: Customizing Orchard, Writing modules
May 11, 2012 at 10:57 PM
Edited May 11, 2012 at 10:58 PM

Hi,

I have a requirement where I have to show some custom fields on the User Profile page. For e.g., FirstName, LastName, Address etc. Additionally, these fields will be populated from the information from our Active Directory, so I don't have to store their values into Orchard's Database.

My question is, how do I go about it? Do I simply make changes in Contrib.Profile module Or should I be writing my own module and use that instead of Contrib.Profile?

Please advice! Thanks!

Coordinator
May 11, 2012 at 11:34 PM

You could write your own module, doing the same as Prfile, which is adding a part to User. But this part would not store things, it would just display the AD information.

May 12, 2012 at 12:01 AM
Edited May 12, 2012 at 12:01 AM

Thanks. Will try that out.

Another question related to this. Consider the scenario, that I have another field/part attached to User Part say avatar image and I want that when system creates the user, a default image gets stored in Orchard. How do I do that ? I am thinking like I would have to get the newly created User Content Item and then update the associated Avatar part with the desired image. Is that a correct approach?

Coordinator
May 12, 2012 at 12:26 AM

There is an event when the user is created. Create an event handler for it in your module. Also what you can do for the AD, is just to create another Driver for the ProfilePart. The n you can reuse the Profile module and create a new one depending on it.

May 14, 2012 at 3:46 PM
Edited May 14, 2012 at 3:54 PM
sebastienros wrote:

1. There is an event when the user is created. Create an event handler for it in your module.

2. Also what you can do for the AD, is just to create another Driver for the ProfilePart. The n you can reuse the Profile module and create a new one depending on it.

1. What event occurs when User is created? Could you please direct me to any module which is doing the same thing as you mentioned above? Also, inside the handler how do I store the photo to the  Avatar part?

2. Do you mean creating the driver inside the Contrib.Profile module itself or a separate custom module?

Thanks

Coordinator
May 14, 2012 at 4:40 PM

You should create a separate module with dependencies on Contrib.Profile and Orchard.Users. You can the reference them, create a driver for ProfilePart, and also implement Orchard.Users.Events.IUserEventHandler to execute custom code when a user is created.

May 15, 2012 at 4:14 PM
Edited May 15, 2012 at 4:14 PM

Another question. I created a custom driver to display AD related information and welded it to the User Content type as per your suggestion. However, it is not getting rendered. Upon debugging, I noticed that none of the methods (Display and Editor) in the Driver are getting hit. What could be the issue? One thing I would like to mention is that initially I after running the code for the first time, I refactored it and changed my part's name from what it was. Could that be a reason ?

May 16, 2012 at 4:17 PM

Got it to work now.