Modifying 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 Querying user profiles. Then, you change the desired values, and finally, you save the changes through the profile manager.

public static void ModifyUserProfile(Guid userId, string newFirstName, string newLastName)
{
    UserProfileManager profileManager = UserProfileManager.GetManager();
    UserManager userManager = UserManager.GetManager();
 
    User user = userManager.GetUser(userId);
 
    SitefinityProfile profile = null;
 
    if (user != null)
    {
        profile = profileManager.GetUserProfile<SitefinityProfile>(user);
 
        profile.FirstName = newFirstName;
        profile.LastName = newLastName;
 
        profileManager.SaveChanges();
    }
}

Next steps

+1-888-365-2779
sales@sitefinity.com

Related topics:

Feedback

How useful is this article?

Tell us more

Submit
Your message was successfully sent.

We appreciate your feedback.

Your message could not be sent.

OK