Blogs and Bloggers

Go Back

Adding Custom Properties to the User Profile

We wanted to add cutom properties to the Users profile, so we could create a members directory control to show the members or employees of a company or organization without having to maintain  separate statis page. But we needed an additional field for the employess biography.

 

So here were my steps.

Sitefinity uses Microsofts Membership provider and RoleManager provider so the first thing we have to do is modify the provider and and a new property.

This is a very simple task, we just modify the web.config file as follows

1.Open the application web.config file. Find this section and add the new profile property:

<profile defaultProvider="Sitefinity">

<providers>

<clear/>

<add name="Sitefinity" connectionStringName="DefaultConnection" applicationName="/" type="Telerik.DataAccess.AspnetProviders.TelerikProfileProvider, Telerik.DataAccess"/>

</providers>

<properties>

<add name="FirstName"/>

<add name="LastName"/>

<add name="Bio"/>

</properties>

</profile>

 

2. To display the field at the Administration > Create/Edit User screens, open the

~/Sitefinity/Admin/CmsAdmin/Users.aspx file add the lines in red:

A.

<cc1:ManageUsers runat="server" ID="manageUsers">

...

<InsertTemplate>

...

<div class="workArea">

<div class="mainForm">

...

<fieldset class="userinfo set">

<cc1:ManageProfile ID="manageProfile" runat="server"

Mode="Insert">

<InsertTemplate>

<ol class="setIn">

<!-- Add the new profile field HERE. For example:

<li>

<cc2:FieldLabel ID="lblBio" runat="server" Text="Bio" TargetID="Nickname"></cc2:FieldLabel>

<asp:TextBox

ID="Nickname"

runat="server"></asp:TextBox>

</li>

-->

B.

<cc1:ManageUsers runat="server" ID="manageUsers">

...

<EditTemplate>

...

<div class="workArea">

<div class="mainForm">

...

<fieldset class="userinfo set">

<cc1:ManageProfile ID="manageProfile" runat="server"

Mode="Insert">

<EditTemplate>

<ol class="setIn">

<!-- Add the new profile field HERE. For example:

<li>

<cc2:FieldLabel ID="lblNickname" runat="server"

Text="Nickname"

TargetID="Nickname"></cc2:FieldLabel><asp:TextBox

ID="Nickname"

runat="server"></asp:TextBox>

</li>

-->

3. To allow users to change their nickname in My Profile, open the

~/Sitefinity/Admin/CmsAdmin/MyProfile.aspx file and add the field as shown below:

<asp:MultiView runat="server" ID="MultiView1">

<asp:View runat="server" ID="ProfileView">

<div class="workArea insert">

<div class="mainForm">

...

<fieldset class="userinfo set">

<cc1:ManageProfile ID="manageProfile" runat="server"

Mode="edit">

<EditTemplate>

<ol class="setIn">

<!-- Add the new profile field HERE. For example:

<li>

<cc2:FieldLabel ID="lblNickname" runat="server"

Text="Nickname"

TargetID="Nickname"></cc2:FieldLabel><asp:TextBox

ID="Nickname"

runat="server"></asp:TextBox>

</li>

-->

Now all we have to do is create a custom Control to display the Users from the Membership provider in a directory page/

Facebook Twitter DZone It! Digg It! StumbleUpon Technorati Del.icio.us NewsVine Reddit Blinklist Add diigo bookmark

Comments  1

  • Tarun 14 May

    Hi,

    Can you help me how to apply some more filter in sitefinity admin area on users in manage user grid . I am putting two separate dropdown on page for filtration Now I need to get data through that filtration.

    I am looking forward for your reply. 

    Thanks!
Post a comment!
  1. Formatting options