Creating user profiles

The following example describes the creating of a user profile separately from the creating of the user. For more information, see the Creating a user example.

In this example, you get the instance of the user that the profile belongs to. To create the profile, you call the CreateProfile method of the manager. Then, you set the desired properties of the profile instance and save the changes.

public static void CreateProfileForUser(string username, string firstName, string lastName)
{
    UserManager userManager = UserManager.GetManager();
 
    User user = userManager.GetUsers().Where(u => u.UserName == username).SingleOrDefault();
 
    if (user != null)
    {
        SitefinityProfile userProfile = profileManager.CreateProfile(user, Guid.NewGuid(), typeof(SitefinityProfile)) as SitefinityProfile;
 
        userProfile.FirstName = firstName;
        userProfile.LastName = lastName;
        profileManager.RecompileItemUrls(userProfile);
        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