Please upgrade your web browser now. Internet Explorer 6 is no longer supported.
Zac Smith
SharePoint, WSS and MOSS development.

How to Customize the User Information Page (Part 2)

by Zac Smith 15-Oct-07, 9 Comments

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:
audit info

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.
Redirected Profile screenshot

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

Categories:
9 responses so far:
  • Sunday, 31 May 2009 08:19 by Prashant Ganesh
    Cool post!! I came across the task to redirect to custom profile page. This post is just what i wanted. thanks
  • Sunday, 31 May 2009 08:19 by asembler
    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.
  • Sunday, 31 May 2009 08:19 by Peter
    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! :-)
  • Sunday, 31 May 2009 08:19 by Zac Smith
    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.
  • Sunday, 31 May 2009 08:19 by Chun
    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
  • Sunday, 31 May 2009 08:19 by Zac Smith
    Chun, I'm aiming to get the next part posted up over the weekend
  • Sunday, 31 May 2009 08:19 by Chun
    Sweet, no pressure but you probably made my Monday just a little bit better.
  • Sunday, 31 May 2009 08:19 by Zac Smith
    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 ...
  • Sunday, 31 May 2009 08:19 by Zac Smith
    Part 3 can now be viewed at: http://zac.provoke.co.nz/archive/2007/10/29/how-to-customize-the-user-information-page-part-3.aspx

 

Post a Comment:
Name:
URL:
Email:
Comments: