User creation with additional field
Blog

User creation with additional field

We always talk about building a community platform using Drupal. In large website we also need lot of user having different roles and associated permission. In this post we are going to explore how can we add users as well adding fields to user profile page. As a site admin, we have ability to add multiple user at any point of time. We can enable permission to allow anonymous users to create new account in your site.

1. How to create a new user account

Step 1.1: Log in as admin.


Step 1.2: Go to Manage >> People

 admin_toolbar

Step 1.3: Once you click on People link, you will be redirected to user adding page.

user_listing_page

Step 1.4: Click on +Add user for new user.

This page requires user email address, Username, Password, Confirm password, Status,    roles, profile picture, locale settings with contact settings.

Email address: The email address of the user, though not required, highly recommended. This information is kept private.

Username: This will be the username for the member and will appear on the site. Spaces are allowed as well as limited punctuation (.-'_).

Password: The user's password. make sure to use a strong password. combination of special character, lower & upper case with numbers and punctuation. Under that you will need to enter the same password again in the Confirm password field.

Status: This allows you to set a user to either Active status or Blocked, meaning they cannot use the site as a member.

Roles: This allows you to give members different roles. The two default roles are Authenticated User user and Administrator. More than one can be selected for a member.

Profile picture: Upload a user avatar in this section if you wish.

Contact settings: Allow other users to contact you via a personal contact form which keeps your email address hidden.

Locale settings: for selecting time zone.

adding_new_user

Step 1.5: Once we have entered user data, click on the Create new account button at the bottom of the page. Your new member will now appear in the list for all users.

added_new_usernew_user_created

like this an admin can add new user to his own site.

2. How to add custom field to user.


Incase if you wants to add few more field for user registration. you can do with few easy step.

Step 2.1: Go to Manage >> Configuration >> Account settings >> Manage fields and click on +Add field. currently i am adding Date of Birth field to user addition page.

people_field_settinglimit_field

 Step 2.2: Once you have saved field setting. it will start appearing on user page.

people_field_settinguser-account-setting-page

 

As we can see the new field “Date of Birth” is listed on user registration page.

creating_new_account

3. Enable Anonymous user to create new account

Similar to Drupal 7, 8 also has feature related to user account setting. These options are to allows admin to enable registration by either Administrators only, Visitors or Visitors, but administrator approval is required.

Drupal 7 user setting page

drupal-7-account-setting

Drupal 8 User settings page

drupal-8-account-setting

 

Option 1:
To check available option, i am selecting Administration only as a option.
In this case Anonymous user won’t get the option to register into Drupal site while visiting drupal-8/user/login.

drupal-8-only-admin-can-register

Option 2: By selecting visitors, anonymous user will get the option to register on site.

drupal-8enabled-anonymou-user-registration

Option 3: By selecting Visitors, but administrator approval is required will help anonymous user to create an account with blocked status. Once admin has approved the particular account will help user to login to the site.

account_created_require_admin_approval

Once admin has changed the user status from Blocked to Active, application will allow specific user to be login to drupal site.