main banner

Content Management

Adding Custom Fields to Sitecore User Part 1

If you’re working with a Sitecore project, you would probably need to add some fields to the user profile such as work phone, zip or social media accounts. Most of the times the first option to achieve this task is to add SQL tables to store the new data for each user, but this approach also implies overriding default behaviors, extending classes and performing additional hard work. Fortunately if you invest some of your time researching at Sitecore documentation, you would find there is a pretty easy way to handle custom fields for Sitecore’s users... and if the situation is favorable you could achieve the goal without a single line of code.

Customizing User Profile for User Manager

According the documentation for Sitecore 6.0,  Sitecore maps each user with a single user profile. The profile contains user’s basic data such as full name, email and portrait and can be extended in order to add new fields that can be manipulated through the User Manager as well as by Sitecore’s API as explained later in this post.

The trick behind extending the user profile lies on the User data template, located at Core database, from which the additional fields could be added. There are two ways to implement custom fields:

  • Extending the Default User Profile.

You just need to add new fields to existing User Profile. The change will be reflected for all users at Master Database.

  • Implementing a Custom User Profile.

Creates new User Profile inheriting the Default profile; all custom fields are encapsulated in this new profile.

You must change at Master database the appropriate user profile through the User Manager to access the custom fields.

Useful to create personalized user profiles based on the domain, country, etc.

Extending the default User Profile for User Manager

To extend existing profile you need to edit the User data template at Core database adding the sections and/or fields that you require. Once the changes were saved, all users at Master database will be ready to set the custom values.  

To perform this approach please follow the next steps:

  1. Select the Core database
  2. Open the Template Manager and select the User item. You can find it in the following path:
  3. templates/System/Security/User
  4. Edit the template adding the fields you need. Sections can be added also.
    Sitecore template manager for custom user profiles
  5. SAVE the changes.
  6. Select Master database and verify the new field is displayed at User Manager/Edit User page
    Sitecore user profile custom fields
    Please notice the custom fields are displayed as Additional Properties at the Profile tab.

Implementing the Custom User Profile

The custom User Profile is created from the Default User data template. At Core database the User Profile data template is  copied and the custom fields are added to the copy, then a new Profile definition must be created based on the new template. And finally the new Profile definition must be assigned to the users at Master database, this way the new fields would be ready to be edited.

To implement the custom user profile proceed with next steps:

  1. Select Core database.
  2. Open Template Manager and duplicate the User data template. Choose a proper name for new profile template... for exercise purposes it will called CustomUserProfile
    Find the user data template under: templates/System/Security/User
  3. Add the custom fields in the CustomUserProfile.
  4. SAVE changes
  5. In Content Editor select the Profile folder: System/Settings/Security/Profiles
  6. Insert the CustomUserProfileDefinition new Item for the profile definition using the CustomUserProfile data template.
    Tip: sort the CustomUserProfileDefinition at the top in order to be the default option when new items were created.
  7. Save your changes.
  8. Select Master database and open User Manager.
    The new profile must be available at Master database.
    You can assign it to the desired users (existing) replaced the default user profile or added to new users.
    Once assigned to the user, you will be able to set the new fields for the selected user.
  9. Set the CustomUserProfile for the given User.
    1. In UserManager, select a user and click on the Edit command. The Edit User dialog will be displayed.
    2. In Edit User dialog click the Profile tab and click the Change button.
      Changing Sitecore user profile to custom user
    3. The Change User profile dialog appears.
      Please notice the profiles are sorted displaying the CustomUserProfile at the top of the list.
    4. In the Change User profile dialog pick up the CustomUserProfile.
      The next time the user profile were displayed the additional fields would be enabled for editing in the Profile tab into the Additional Properties section.
      Sitecore custom user profile dialog with new fields
Luis G.

An expert we all come to when in doubt, Luis was born in Monterrey and has a B.S. Electronic Systems Engineering degree His multiple abilities are backed 10 years of experience in .NET, SQL and recently joined the ranks of front end developers. A Star Wars and Lego enthusiast, he is also a loving father and a very friendly co-worker who writes for the Inflection Point’s blog with lots of inspiration and fills our blog with descriptions of our work environment that recall us all of the good times.