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.
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:
You can use the DoesFieldExist extension method from the Telerik.Sitefinity.Model namespace to check if the user contains a particular field.
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:
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important
Copyright © 2022 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, Ipswitch, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.
Powered by Progress Sitefinity