Chapter 7: Managing User Accounts
- Concept: Users, Roles, and Permissions
- Concept: The User 1 Account
- Creating a Role
- Creating a User Account
- Assigning Permissions to a Role
- Changing a User's Roles
- Assigning Authors to Content
Concept: Users, Roles, and Permissions
What are Users?
Anyone who visits your website is a user, including you. There are three groups of users:
- Users who are not logged in, or anonymous users
- Users who are logged in, or authenticated users
- The administrative user account that was automatically created when you installed your site, or User 1. See Concept: The User 1 Account.
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:
- A Vendor role that allows vendors to edit their own vendor listing page
- A Content editor role for editing the general farmers market pages
- A User manager role for managing the vendor accounts
- The Administrator role that was installed with your site, for expert users to manage the site configuration
Related topics
- Creating a Role
- Assigning Permissions to a Role
- Changing a User's Roles
- Creating a User Account
- Concept: The User 1 Account
- Assigning Authors to Content
Additional resources
- Drupal.org community documentation page "Managing Users"
- Drupal.org community documentation page "User Roles"
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:
- Some actions and updates on the site are logged, and if everyone uses the same account, it is difficult to know who did them if you have questions.
- The Administrator role permissions can be modified to be safer than the full permissions of the user 1 account, so that people do not inadvertently change site features that shouldn't be changed.
- People's responsibilities on a site may change over time. With ordinary user accounts, this can be mirrored in permissions by assigning or unassigning roles to their user accounts. If they are all using the user 1 account, this is more difficult.
- On some sites, the author of content or comments is displayed or tracked, and if everyone uses the same account to create content, it is difficult to know who created the content.
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
- In the Manage administrative menu, navigate to People > Roles (admin/people/roles).
- You will find default roles Anonymous user,
Authenticated user, and Administrator already present.
- Click Add Role to add a custom role.
- Type Vendor in the Role name field. Click Save.
- You will see the message "Role Vendor has been added." displayed at the top
of the page.
Expand your understanding
Videos
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
- In the Manage administrative menu, navigate to People (admin/people).
- Click Add user.
- 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 - Click Create new account. You will get a notification about the user account
creation.
- Create a second Vendor account for Happy Farm by following the steps above.
Expand your understanding
Create a user account for yourself.
Videos
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
-
In the Manage administrative menu, navigate to People > Roles (admin/people/roles). The Roles page appears.
-
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.
-
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 -
Click Save permissions. You will get a message saying your changes have been saved.
Expand your understanding
- Log in as one of the new users you created in Creating a User Account. Verify whether you have the correct permissions.
- Changing a User's Roles
Related concepts
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
- In the Manage administrative menu, navigate to People (admin/people).
- 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.
- Click Edit to update the user account.
- On the Edit page, scroll down to Roles section. Check the Administrator
role for the user account.
- 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.
Updating the roles using bulk editing method
- 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).
- 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.
- Select Add the Vendor role to the selected user(s) from the Action
select list.
- Click Apply to selected items. You should see a message indicating that the
desired changes were made.
Videos
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
- The Vendor content type must exist, and your site must have at least two Vendor content items. See Adding a Content Type, Adding Basic Fields to a Content Type, and Creating a Content Item.
- User accounts for at least two vendors must exist. See Creating a User Account.
Steps
- In the Manage administrative menu, navigate to Content (admin/content).
- 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.
- 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.
- Click Save.
- You will get a notification that the Vendor content item has been updated.
- Follow these steps again to assign Vendor content item Sweet Honey to the Vendor user account Sweet Honey.