# Create user profiles

The following example demonstrates the creating of a user profile separately from the creating of the user. For more information, see the [Create users](https://www.progress.com/documentation/sitefinity-cms/for-developers-create-users) 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.

```C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerik.Sitefinity.Security;
using Telerik.Sitefinity.Security.Model;

namespace SitefinityWebApp
{
    public partial class UserProfilesSnippets
    {
        public static void CreateProfileForUser(string username, string firstName, string lastName)
        {
            UserProfileManager profileManager = UserProfileManager.GetManager();
            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();
            }
        }
    }
}
```

If you have extended the user profile with additional custom fields, you can also set values for these fields. For more information on adding custom fields, see [Custom fields](https://www.progress.com/documentation/sitefinity-cms/overview-custom-fields).

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

* JobTitle\
  Short text
* Age\
  Number

```C#
using System;
using System.Linq;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity.Security;
using Telerik.Sitefinity.Security.Model;

namespace Telerik.Sitefinity.Documentation.CodeSnippets.DeepDive.Security.Users
{
    public partial class UserProfilesSnippets
    {
        public static void CreateProfileForUserWithCustomFields(string username, string firstName, string lastName, string jobTitle, decimal age)
        {
            UserProfileManager profileManager = UserProfileManager.GetManager();
            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;

                //Checks whether the user profile contains a JobTitle field and sets its value
                if (userProfile.DoesFieldExist("JobTitle"))
                    userProfile.SetValue("JobTitle", jobTitle);

                //Checks whether the user profile contains an Age field and sets its value
                if (userProfile.DoesFieldExist("Age"))
                    userProfile.SetValue("Age", age);

                profileManager.SaveChanges();
            }
        }
    }
}

```

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