Modify user profiles

The following example describes how to modify a user profile by changing the first name and last name values.

To modify a profile, you get an instance of the profile. In this example, you get the instance of the profile by the ID of the user. For more information, see For developers: Query user profiles. Then, you change the desired values, and finally, you save the changes through the profile manager.


Modifying user profile custom fields

If you've extended the user profile with additional custom fields, you can also get and set values for these fields. Since custom fields cannot be part of the predefined data model for user profiles, they do not appear automatically as properties you can work with. You must use the GetValue and SetValue extension methods when working with user profile custom fields. For more information on adding custom fields, see Overview: Custom fields.

In the following example the user profile has two additional custom fields added:

  • JobTitle
    Short text
  • Age



You can use the DoesFieldExist extension method from the Telerik.Sitefinity.Model namespace to check if the user contains a particular field.

Modifying custom user profile types

Custom user profile types enable you to group multiple custom fields in their own profile type. For more information about custom profiles see: Create profile types.

When working with custom profile types you are working with an object of type UserProfile, unlike the previous samples which were demonstrating working with the default SitefinityProfile type.To get the custom profile you need to pass the profile type name to the GetUserProfile overload of UserProfileManager. The name is displayed when you're creating the custom profile type. If you are not sure about the custom profile type name, it consists of the Telerik.Sitefinity.Security.Model namespace and the name of your custom user profile in lowercase. For example, if you have a custom user profile named AdvancedProfile, the profile type name for that profile is "Telerik.Sitefinity.Security.Model.advancedprofile". Once you have an instance of the custom profile in your code, working with the custom profile fields is done in the same way as working with custom fields for the default user profile. The following sample demonstrates working with custom profiles and their fields:

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?

Next article

Delete user profiles