Tuesday, November 10, 2015

Sitecore custom properties on a user profile

In Sitecore, by default there are a number of fields which are set on a user profile. These include such details as: full name, email address, password, comment, etc. It can be a requirement with a specific Sitecore implementation to store a number of custom fields against each user profile, perhaps mailing address details for example.

Instead of using custom SQL databases or Sitecore items, you can actually create a Sitecore template and have that appear on the user profile (as custom properties). To achieve this, you will need to complete the following steps:

Creating the custom profile

  1. From the Sitecore desktop, switch to the Core database

  2. Open the content editor and navigate to /sitecore/templates/System/Security, and insert a new template, in this case I have called it CustomProfile.
  3. As with any Sitecore template, create the desired fields you wish stored against each profile.

  4. Whilst still using the Core database, navigate to /sitecore/system/Settings/Security/Profiles and insert your CustomProfile template under the existing User item.

  5. Take note of the ID of the CustomProfile item, and then switch your database back to Master.

Adding the custom profile to a user and editing the fields

To assign this custom profile to a user you simply need the ID of the profile, and will assign the profile programatically.

You can then see the custom profile has been added to the user, by viewing it in the User Manager from the Sitecore desktop.

The custom profile properties can be set there, or done so via code:

No comments:

Post a Comment