Please upgrade your web browser now. Internet Explorer 6 is no longer supported.
Thinking Web Solutions?
We create smart, fun, functional websites that make your web a better place.

How to Customize the User Information Page (2/3)

Liam Cleary recently wrote a blog post on how to "Hide the My Settings link" which is part of the welcome menu. Although his solution is perfectly valid and probably quicker and easier than the alternative solution that I offer - It did have some issues.
Firstly he edited the welcome.ascx user control. Like editing an application page this will affect all sites for that instance of SharePoint.
Secondly this only covers the scenario where the user actually clicks on the "My Settings" link. There are many other access points to the User Information page. For example any list edit/display form will have a link to the page. Thats any instance where you see the following audit info:
auditinfo

So creating a custom "My Settings" link only covers half the problem.

The question then is - how to create a solution that doesn't involve editing shared resources and covers every possible link scenario??
The answer lies in the userdisp.aspx page. In the AdditionalPageHead placehoder tag you will find the following control declaration:
<SharePoint: DelegateControl runat="server" id="DelctlProfileRedirection" ControlId="ProfileRedirection" Scope="Farm" />

What we need to do is create a user control, that redirects the user to a custom page. The user control will the be activated via a feature.

Brief Steps:

  1. Create a custom user display page and place it in the LAYOUTS directory.
  2. Create a new User Control that has code to redirect the user to your custom page.
  3. Create a feature for the delegate control. This feature will cause your custom control to run in place of the SharePoint:DelegateControl declaration. The feature should be scoped to "farm".

I have kept the steps very brief as I have a sample solution with all the necassary code in it.
Download the sample code from here:
http://zac.provoke.co.nz/Samples/CustomUserProfile.zip

To run the sample, copy CustomUserProfile.wsp file and Deploy.cmd to your WSS server and run the following command from a prompt:
deploy.cmd http://yoursitenamehere

Once the feature is activated, navigating to My Settings page will redirect the user to userprofile.aspx.
redirectedprofile

Not a very useful custom profile page, but thats what part 3 is for :)

The only problem now is that the feature's scope is set to farm, so the user control will be run for all sites. To solve this you can create a second feature, and then before redirecting check for the features existance. This is also included in the sample solution.

Part 3 will show how to easily customise the actual User Profile page.

For more info on delegate controls have a look at the following resources:
http://msdn2.microsoft.com/en-us/library/ms470880.aspx
http://sharepointnutsandbolts.blogspot.com/2007/06/using-delegate-control.html

12 comments for “How to Customize the User Information Page (2/3)”

  1. Prashant Ganesh  10/15/2007

    Cool post!! I came across the task to redirect to custom profile page. This post is just what i wanted. thanks

  2. asembler  10/15/2007

    Hi Zac, Great article. Whould this work if I wanted to direct users to their Profile pages on MySite (given of course MySites are enabled)? How would I dinamically determine what mysite part of the URL should be? Thanks.

  3. Peter  10/15/2007

    Very clever solution to a problem I myself was struggling with a few months ago. Thanks! :-) Not knowing about the DelegateControl I ended up developing a HTTP Module, that would monitor the request for userdisp.aspx, and redirect to a custom page instead. Problem with that approach was that IF a second web application was created to zone to the main application, a new web.config would be created but without the HTTP Module installed by default. But I'm curious as to why you made this a Farm-scoped feature? Maybe to deal with the problems of having multiple web applications pointing to the same site? I really have to investigate further into what the -element of the Elements.xml is capable of. Your elegant solution opened my eyes to what other scenarios can be dealt with by using the -element. Cheers! :-)

  4. Zac Smith  10/15/2007

    Thanks for the comments Peter. The reason I scoped the feature to the farm was because thats how the delegate was declared in userdisp.aspx. As the idea was not to edit that file I needed another solution - hence the extra feature. Another way of doing it could have been to add properties to the feature that specified what sites should have redirects enabled.

  5. Chun  10/15/2007

    Zac, Thanks for the great article, it appeared just at the right time, but is there an ETA on part 3, or anything can send me pre your next blog on the matter? Chun

  6. Zac Smith  10/15/2007

    Chun, I'm aiming to get the next part posted up over the weekend

  7. Chun  10/15/2007

    Sweet, no pressure but you probably made my Monday just a little bit better.

  8. Zac Smith  10/15/2007

    Sorry for the delay Chun but I won't be able to post up Part 3 till tomorrow morning. It's almost done so not long to wait ...

  9. Mohammed Jarood  12/1/2010

    Hi,

    Can you please repost the solution files. The links in these posts are not working.

    Regards
    Jarood

  10. Robert Wagenaar  3/5/2011

    Hi,

    I would also like to download the solution fields. As Jarood points ount, the links are not working now.

    Greetings,

    Robert

  11. Zac  5/17/2011

    Really sorry guys but I think the file was left behind when we last moved servers. I will have another look but it's likely gone.

  12. Craig S  9/13/2011

    Noooooo! Looks like you did great work here, too bad you can't find the source files. If anyone has them, it would be great to get a copy.

Post a comment