Working with users

In this series of tasks, we will explore Drupal's user functionality, which allows you to add users to your site and specify the functionality that they can use. We will also discuss the concept of roles, which allow you to create a group of permissions that can easily be assigned to users. Finally, we will discuss how to assign roles to the users.

Allowing user registration

Good Eatirt Goal: Allow users to register on the web site so that they can access additional content that is not available to unregistered visitors.

Additional modules needed: None.

Drupal contains a sophisticated system of user management and permissions that allows you to easily control who can access your web site and what they can do on the web site.

Interacting With Customers and Visitors

Basic steps

1. Settings related to user registration are controlled from the User Settings page, which is available by selecting User management and then User settings, from the Administer menu. The first section, shown below, controls the registration process that a new visitor must go through to sign up at the web site.

User registration settings Public registrations:

O Only site administrators can create new user accounts. ® Visitors can create accounts and no administrator approval is required. O Visitors can create accounts but administrator approval is required.

0 Require e-mail verification when a visitor creates an account

If this box is checked, new users will be required to validate their e-mail address prior to logging Into the site, and will be assigned a system-generated password. With It unchecked, users will be logged In immediately upon registering, and may select their own passwords during registration.

User registration guidelines:_

This text is displayed at the top of the user registration form and Is useful for helping or instructing your users

2. The default settings will allow anyone to register for your web site without any interaction from a site administrator. Chef Wanyama is interested in controlling access to the site and wants to approve user registration requests before they are activated. This will help him recognize special customers to include in his VIP club and make sure that only the customers living near his restaurant are registered.

3. Change the Public registrations option to Visitors can create accounts but administrator approval is required. You can also enter some guidelines to help the user understand the process.

4. The next section controls the format of emails that are sent to the users at various stages of the registration process.

5. Finally, you can control whether or not users can add signatures and pictures when they submit comments and forum posts. Users of a social site may wish to provide a signature to give other users information about themselves. However, on the Good Eatin' site, signatures and pictures aren't necessary.

Chapter 4

Create a VIP role

Good Eatirt Goal: Create a VIP role that will be used to give special customers enhanced privileges that normal customers do not have. Customers must be granted VIP access; they cannot sign up for it.

Additional modules needed: None.

Basic steps

1. Drupal allows you to manage roles for the web site on the Roles Manager page, which can be accessed by selecting User Management and then Roles, from the Administer menu.

2. After you open the Roles Manager, Drupal will display a list of the roles currently available on your site, and also provide you with the ability to add a new role, as shown below:


Roles allow you to fine tune the security and administration of Drupal. A role defines a group of users that have certain privileges as defined in user permissions. Examples of roles include: anonymous user, authenticated user, moderator, administrator and so on. In this area you will define the role names of the various roles. To delete a role choose "edit".

By default, Drupal comes with two user roles:

• Anonymous user: this role is used for users that don't have a user account or that are not authenticated.

• Authenticated user: this role is automatically granted to all logged in users.

Name Operations

• Anonymous user: this role is used for users that don't have a user account or that are not authenticated.

• Authenticated user: this role is automatically granted to all logged in users.

Name Operations

anonymous user

locked edit permissions

authenticated user

locked edit permissions

I Add role |

3. Enter VIP user for the name and then press Add role. Drupal will now add the role to the Roles Manager as shown below:


Interacting With Customers and Visitors_

4. From the manager, you can edit the role, which will allow you to modify the name for the role, or delete the role.

5. Once the role has been created, you need to update the permissions for the role so that the user can perform the tasks that they need to. To modify the permissions, click on the edit permissions link for the role.

6. Drupal will then display a list of all of the available permissions, arranged by category. By default, all permissions are disabled. This prevents new user roles from gaining unwanted access. When a user is assigned to more than one role, their actual permissions will be a combination of the permissions of each role. This means that you should give each role as few permissions as possible, and assign multiple roles to a user in order to fully define each user.

7. For our VIP role, we will only add the post comments without approval permission, and then click the Save permissions button to finish the changes.

Assign users to the VIP role

Good Eatin' Goal: Change a registered customer to a VIP customer and let them know that they have been given additional privileges.

Additional modules needed: None.

Basic steps

Now that we have built the new VIP role, we can assign users to the role. Chef Wanyama wants to assign his VIPs manually, but you can also allow visitors to request a different role, or assign roles at sign-up.

1. To create a new user with a VIP role, we will start at the User Manager, which is accessed by selecting User management and then Users, from the Administer menu.

2. Next, click on the Add user link. Drupal will display a form where you can enter information about the user who is to be added, as shown in the following screenshot:

Chapter 4


This web page allows administrators to register new users. Users' e-mail addresses and usemames must be unique.

Username: *

Spaces are allowed; punctuation ¡Is not allowed except for periods, hyphens, and underscores. E-mail address: *

A valid e-mail address. All e-mails from the system will besentto this address. The e-mail address is not made public andwill only be used if you wish to receive a new password or wish to receive oertain news or notifications by e-mail.

Password: *

Confirm password: *_

Provide a password for the new account in both felds. Status:

O Blocked © Active Roles:

E authenticated user

□ Notify user of new account | Create new account"]

3. Enter the required information about the new user, including a password. To make the user a VIP user, select the VIP user checkbox in the Roles section.

4. If a user has already signed up, you can add a role for him or her by clicking on the user from the User Manager page, clicking on the edit link, and then simply selecting the checkbox for the role that you want to add.

Notification on sign up

Good Eatin' Goal: Set up a notification system so that web site administrators can be notified each time a new user registers on the web site. This can help you to quickly review new members and follow up with them to ensure that they have a positive experience on the site.

Additional modules needed: Trigger (Core).

Interacting With Customers and Visitors_

In order to notify administrators when a user has signed up, we will need to do two things. First, we will need to build an action that creates and sends the email. The second thing we need to do is create a trigger that tells Drupal when the email should be sent. Let's begin by creating the action.

Creating the email action

1. Actions are created by using the Actions Manager, which is accessed by selecting Site Configuration and then Actions, from the Administer menu.

2. As you can see in the following image, there are several basic actions that can be used. Alternatively, you can create your own actions.


Actions are individual tasks that the system can do, such as unpublishing a piece of content or banning a user. Modules, such as the trigger module, can fire these actions when certain system events happen; for example, when a new post is added or when a user logs in. Modules may also provide additional actions.

There are two types of actions: simple and advanced. Simple actions do not require any additional configuration, and are listed here automatically. Advanced actions can do more than simple actions; for example, send an e-mail to a specified address, or check for certain words within a piece of content. These actions need to be created and configured first before they may be used. To create an advanced action, seiect the action from the drop-down below and click the Create button.

Actions available to Drupal: Action type Description


Unpublish comment


Publish post


Unpublish post


Make post sticky


Make post unsticky


Promote post to front page


Remove post from front page


Save post


Block current user


Ban IP address of current user

Make a new advanced action available

Make a new advanced action available

Choose an advanced action v 11 Create |

As there is no basic action for emailing the administrator, we will need to create a new action.

3. Begin by selecting Send email from the Advanced Options drop-down list and then click Create.

_Chapter 4

4. Drupal will then display a form where you can enter information about the email that is to be sent, as shown below:

Configure an advanced action

An advanced action offers additional configuration options which may be filled out below. Changing the Description field is recommended, in order to better identify the precise action taking place. This description will be displayed in modules such as the trigger module when assigning actions to system events, so it is best if it is as descriptive as possible (for example, "Send e-mail to Moderation Team" rather than simply "Send e-mail").


|New User Email |

A unique description far this advanced action. This description will be displayed In the Interface of modules that Integrate with actions su<Ji as Trigger module.


|[email protected] |

Theemail address towtiirti the message should besent OR enter %author If you would llketosend an e-mail to tfie author of the original post


|A New User Registered registered on %srte_name |

The subject of the message.


A new user registered on %site_name with the user name %username. To approve this user, please login to %srte_name. And visit the User Manager.

The %srte name team.

Themessage tfiatshould besent You may include tfiefollowlngvariables: %site_name, %username, %node_uri, %node_type, •Stifle, %teaser, Wbody. Not all variables will be available In all contexts.

5. Click on Save and the action will be added to the Action Manager. You can modify the email at any point by clicking on the configure link, or you can delete the action by clicking delete.

Creating the new user trigger

We now need to create the Trigger that will determine when our new email is to be sent.

1. Begin by enabling the Trigger module, which is installed as part of the core Drupal installation.

2. Once the Trigger module has been installed, you can access the Trigger manager by selecting Site building and then Triggers, from the Administer menu. The Trigger Manager is divided into several sections, depending on its usage.

T This material is copyright and is licensed for the sole use by Melissa Ziebell on 20th February 2009 P^^ I 131 Wentz Street, , Philadelphia, PA, 19120


Interacting With Customers and Visitors_

3. To access the manager for user-related Triggers, click on the Users tab in the Trigger Manager. Drupal will display a list of all possible Triggers, and you can assign actions to each as shown in following screenshot:


Triggers are system events, such as when new content is added or when a user logs in. Trigger module combines these triggers with actions (functional tasks), such as unpublishing content or e-mailing an administrator. The Actions settings page contains a list of existing actions and provides the ability to create and configure additional actions.

Below you can assign actions to run when certain user-reiated triggers happen. For example, you could send an e-mail to an administrator when a user account is deleted.

Trigger: After a user account has been created | New User Email [ Assign J

Trigger: Atter a users profile has been updated | Choose an action [ Assign J

Trigger: Atter a user has been deleted | Choose an action | Assign |

Trigger: After a user has logged in | Choose an action [ Assign J

Trigger: After a user has logged out No available actions for this trigger.

Trigger: When a user's prof le is being viewed | Choose an action | Assign |

4. Change the action for the Trigger: After a user account has been created to

New User Email and then click Assign. Drupal will add the action and save the form. The administrator will then be automatically emailed each time a new user account is created. If you want to disable this action in the future, simply click the unassign link in the Trigger Manager.

Was this article helpful?

+2 0


  • Sofia
    How do I approve a user request in drupal?
    9 years ago
    Who can add user to a group drupal?
    9 years ago

Post a comment