# Create users

When creating a user, you must perform the following steps:

1. Get instances of the user and user profile managers.\
   The managers are represented by the `UserManager` and `UserProfileManager` classes. For more information about getting their instances, see [Users](https://www.progress.com/documentation/sitefinity-cms/for-developers-users).
2. Create the user.\
   To create the user, call the `CreateUser` method of the `UserManager` class and pass the required arguments. The `CreateUser` method accepts an output parameter of type `System.Web.Security.MembershipCreateStatus` that provides information about the result of the operation. The method returns the instance of the created user.
3. Check whether the user has been created successfully.\
   If the user has been created successfully, the value of the output parameter must be equal to `MembershipCreateStatus.Success`.
4. Create a user profile for the user.\
   If the user has been created successful, create a respective user profile. To do this, call the `CreateProfile` method of the `UserProfileManager` class and pass the required parameters. For the type of profile, use `SitefinityProfile`. For more information, see [CRUD operations with user profiles](https://www.progress.com/documentation/sitefinity-cms/for-developers-user-profiles).
5. Save the changes.\
   Finally, save the changes to both `UserManager` and `UserProfileManager`.

Here is a code example:

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

namespace Telerik.Sitefinity.Documentation.CodeSnippets.DeepDive.Security.Users
{
    public partial class ManagingUsersSnippets
    {
        public static MembershipCreateStatus CreateUser(string username, string password, string firstName, string lastName, string mail, string secretQuestion, string secretAnswer, bool isApproved)
        {
            UserManager userManager = UserManager.GetManager();
            UserProfileManager profileManager = UserProfileManager.GetManager();

            System.Web.Security.MembershipCreateStatus status;

            User user = userManager.CreateUser(username, password, mail, secretQuestion, secretAnswer, isApproved, null, out status);

            if (status == MembershipCreateStatus.Success)
            {
                SitefinityProfile sfProfile = profileManager.CreateProfile(user, Guid.NewGuid(), typeof(SitefinityProfile)) as SitefinityProfile;

                if (sfProfile != null)
                {
                    sfProfile.FirstName = firstName;
                    sfProfile.LastName = lastName;
                }

                userManager.SaveChanges();
                profileManager.RecompileItemUrls(sfProfile);
                profileManager.SaveChanges();
            
            }

            return status;
        }
    }
}

```
