Chapter 7: Managing User Accounts

Concept: Users, Roles, and Permissions

What are Users?

Anyone who visits your website is a user, including you. There are three groups of users:

What are Permissions?

The ability to do actions on your site (including viewing content, editing content, and changing configuration) is governed by permissions. Each permission has a name (such as View published content) and covers one action or a small subset of actions. A user must be granted a permission in order to do the corresponding action on the site; permissions are defined by the modules that provide the actions.

What are Roles?

Rather than assigning individual permissions directly to each user, permissions are grouped into roles. You can define one or more roles on your site, and then grant permissions to each role. The permissions granted to authenticated and anonymous users are contained in the Authenticated user and Anonymous user roles, and depending on the installation profile you used when you installed your site, there may also be an Administrator role that is automatically assigned all permissions on your site.

Each user account on your site is automatically given the Authenticated user role, and may optionally be assigned one or more additional roles. When you assign a role to a user account, the user will have all the permissions of the role when logged in.

It is a good practice to make several roles on your site. In the farmers market site example, you might want the following roles:

Additional resources

Concept: The User 1 Account

Prerequisite knowledge

Concept: Users, Roles, and Permissions

What is the user 1 account?

During the installation of your site, you created the first user account. Each user account internally has a numeric user ID, and since the ID of this user is one, it is commonly referred to as the user 1 account. This user account is special, because independent of what roles it is assigned, someone logged in as user 1 has permission to do all actions on the site, including viewing and editing all content, editing any user account, changing site configuration, installing and uninstalling modules, and running the update script.

Because of this level of permission, some people refer to this account as the root user, similar to the "root" user account that has full administrative permissions in Linux and other operating systems.

It is usually better to make separate accounts for each administrative user, giving them the Administrator role, rather than having all administrative users log in using the user 1 account. There are several reasons for this:

It is not possible to delete the user 1 account from the administrative user interface. It would be possible to do with a database query, but it could cause problems in your site and is not advisable.

Additional resources

Drupal.org community documentation page "Accounts and roles"

Creating a Role

Goal

Create a Vendor role to allow some - but not all - users to perform specific tasks.

Prerequisite knowledge

Concept: Users, Roles, and Permissions

Steps

  1. In the Manage administrative menu, navigate to People > Roles (admin/people/roles).
  2. You will find default roles Anonymous user, Authenticated user, and Administrator already present. Roles page
  3. Click Add Role to add a custom role.
  4. Type Vendor in the Role name field. Click Save. adding vendor as a role
  5. You will see the message "Role Vendor has been added." displayed at the top of the page. vendor role added success message

Expand your understanding

Videos

Creating a Role

Additional resources

Drupal.org community documentation page "User Roles"

Creating a User Account

Goal

Create Vendor user accounts for Sweet Honey and Happy Farm vendors.

Prerequisite knowledge

Site prerequisites

The Vendor role must exist on your site. See Creating a Role.

Steps

  1. In the Manage administrative menu, navigate to People (admin/people).
  2. Click Add user. Form for creating a new user account
  3. Fill in the form fields. See the table below.
    Field name Explanation Example value
    Email address A valid email address for the vendor. All emails from the system will be sent to this address. The email address is not made public. honey@example.com
    Username A username for the vendor that they will use to sign in or author content items. Spaces are allowed; punctuation is not allowed except for periods, hyphens, apostrophes, and underscores. Sweet Honey
    Password A password the vendor will use to sign in to the site. You can see how safe the password is on the _Password strength_ gauge. You also get tips on how to make it safer. (Make a secure password)
    Confirm password Type the same password to avoid any typing mistakes. (Repeat password)
    Status Set the status of the user account. _Blocked_ users will not be able to sign in. Active
    Roles Set the role of the user account. Vendor
    Notify user of new account Whether or not to send a notification to the vendor's email address. Checked
    Picture Click _Browse_ and select a picture to upload. Pay attention to size restrictions. Photo of the vendor
    Contact settings Enable or disable the display of a contact form for the account. Checked
  4. Click Create new account. You will get a notification about the user account creation. New user account has been created
  5. Create a second Vendor account for Happy Farm by following the steps above.

Expand your understanding

Create a user account for yourself.

Videos

Creating a User Account

Assigning Permissions to a Role

Goal

Change the permissions for the Vendor role so that users can create, edit, and delete Recipe and Vendor content, format the content, and contact each other.

Prerequisite knowledge

Site prerequisites

The Vendor role must exist on your site. See Creating a Role.

Steps

  1. In the Manage administrative menu, navigate to People > Roles (admin/people/roles). The Roles page appears.

  2. Click Edit permissions in the dropdown for the Vendor role. The Edit role page appears where you can see all the available actions for the website such as, for example, Post comments or Administer blocks. The available permissions depend on the modules that are installed in the site. Note: Some permissions may have security implications. Be cautious while assigning permissions to roles.

  3. Check the boxes for the following permissions, listed by module:

    Module Permission
    Contact Use users' personal contact forms
    Filter Use the Restricted HTML text format
    Node Recipe: Create new content
    Node Recipe: Edit own content
    Node Recipe: Delete own content
    Node Vendor: Edit own content
    Granting users with the Vendor role the rights to create, delete and edit Recipes
  4. Click Save permissions. You will get a message saying your changes have been saved. Confirmation message after updating permissions

Expand your understanding

Concept: The User 1 Account

Videos

Assigning Permissions to a Role

Additional resources

Drupal.org community documentation page "Managing Users"

Changing a User's Roles

Goal

Change or add roles to a given user, either by editing a single-user or by applying a bulk operation.

Prerequisite knowledge

Concept: Users, Roles, and Permissions

Site prerequisites

The user account that you want to update, and the role you want it to have, must already exist. See Creating a User Account, Creating a Role, and Assigning Permissions to a Role.

Steps

Updating the roles using single-user editing method

  1. In the Manage administrative menu, navigate to People (admin/people).
  2. Locate the user 1 account (named "admin") to assign it the Administrator role. If it is not immediately visible, use the Name or email contains filter, or other filters, to narrow down the list.
  3. Click Edit to update the user account. People page
  4. On the Edit page, scroll down to Roles section. Check the Administrator role for the user account. Roles section of user edit page
  5. Click Save to update the user account. You should be returned to the People page and see a message saying that the changes have been saved. Confirmation message

Updating the roles using bulk editing method

  1. If the users Happy Farm and Sweet Honey did not already have the Vendor role, here is how you would add it. In the Manage administrative menu, navigate to People (admin/people).
  2. Locate Vendor user accounts Sweet Honey and Happy Farm and check them. If they are not immediately visible, use the Name or email contains filter, or other filters, to narrow down the list.
  3. Select Add the Vendor role to the selected user(s) from the Action select list. People page with bulk operation set up
  4. Click Apply to selected items. You should see a message indicating that the desired changes were made. Confirmation message

Videos

Changing a User

Assigning Authors to Content

Goal

Assign Vendor content items Happy Farm and Sweet Honey to the corresponding Vendor user accounts, so they can edit their own Vendor profiles on the site.

Prerequisite knowledge

Site prerequisites

Steps

  1. In the Manage administrative menu, navigate to Content (admin/content).
  2. Find Vendor content item Happy Farm in the list. If it is not immediately visible, you can filter the list by Published status, Content type (Vendor), Title, or Language. Click Edit for the Vendor content item you would like to assign an author to.
  3. Under Authoring information, start typing the Vendor's user name Happy Farm in the Authored by field. The field lists matching user names. Select the Vendor's user name from the list. Assigning an author to the Vendor content item
  4. Click Save.
  5. You will get a notification that the Vendor content item has been updated. Vendor content item has been updated
  6. Follow these steps again to assign Vendor content item Sweet Honey to the Vendor user account Sweet Honey.

Videos

Assigning Authors to Content