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.
GetValue
SetValue
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:
UserProfile
SitefinityProfile
GetUserProfile
UserProfileManager
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important