What are we going to do and why?
Before we get started, let’s take a closer look at what we are going to do in this article and why. At the moment, our users can interact with the website and contribute content, including through their own personal blog. Apart from the blog, there isn’t a great deal which differentiates our users; they are simply a username with a blog! One key improvement to make now is to make provisions for customizable user profiles. Our site being a social network with a dinosaur theme, the following would be useful information to have on our users:
- Details of their pet dinosaurs, including:
- Date of birth
- Their details for other social networking sites; for example, links to their Facebook profile, Twitter account, or LinkedIn page
- Location of the user (city / area)
- Their web address (if they have their own website)
Some of these can be added to user profiles by adding new fields to profiles, using the built in Field API; however we will also install some additional modules to extend the default offering.
Many websites allow users to upload an to associate with their user account, either a photograph or an avatar to represent them. Drupal has provisions for this, but it has some drawbacks which can be fixed using Gravatar. Gravatar is a social avatar service through which users upload their avatar, which is then accessed by other websites that request the avatar using the user’s e-mail address. This is convenient for our users, as it saves them having to upload their avatars to our site, and reduces the amount of data stored on our site, as well as the amount of data being transferred to and from our site. Since not all users will want to use a third-party service for their avatars (particularly, users who are not already signed up to Gravatar) we can let them upload their own avatars if they wish, through the Upload module.
There are many other social networking sites out there, which don’t complete with ours, and are more generalized, as a result we might want to allow our users to promote their profiles for other social networks too. We can download and install the Follow module which will allow users to publicize their profiles for other social networking sites on their profile on our site.
Once our users get to know each other more, they may become more interested in each other’s posts and topics and may wish to look up a specific user’s contribution to the site. The tracker module allows users to track one another’s contributions to the site. It is a core module, which just needs to be enabled and set up.
Now that we have a better idea of what we are going to do in this , let’s get started!
Getting set up
As this article covers features provided by both core modules and contributed modules (which need to be downloaded first), let’s download and enable the modules first, saving us the need for continually downloading and enabling modules throughout the article.
The modules which we will require are:
- Tracker (core module)
- Gravatar (can be downloaded from: http://drupal.org/project/gravatar)
- Follow (can be downloaded from: http://drupal.org/project/follow)
- Field_collection (can be downloaded from:http://drupal.org/project/field_collection)
- Entity (can be downloaded from:http://drupal.org/project/entity )
- Trigger module (core module)
These modules can be downloaded and then the contents extracted to the /sites/all/modules folder within our Drupal installation. Once extracted they will then be ready to be enabled within the Modules section of our admin area.
Users, roles, and permissions
Let’s take a detailed look at users, roles, and permissions and how they all fit together. Users, roles, and permissions are all managed from the People section of the administration area:
Within the People section, users are listed by default on the main screen. These are user accounts which are either created by us, as administrators, or created when a visitor to our site signs up for a user account. From here we can search for particular types of users, create new users, and edit users—including updating their profiles, suspending their account, or delete them permanently from our social network.
Once our site starts to gain popularity it will become more difficult for us to navigate through the user list. Thankfully there are search, sort, and filter features available to make this easier for us. Let’s start by taking a look at our user list:
(Move the mouse over the image to enlarge.)
This user list shows, for each user:
- Their username
- If their user account is active or blocked (their status)
- The roles which are associated with their account
- How long they have been a member of our community
- When they last accessed our site
- A link to edit the user’s account
Users: Viewing, searching, sorting, and filtering
Clicking on a username will take us to the profile of that particular user, allowing us to view their profile as normal. Clicking one of the headings in the user list allows us to sort the list from the field we selected:
This could be particularly useful to see who our latest members are, or to allow us to see which users are blocked, if we need to reactivate a particular account.
We can also filter the user list based on a particular role that is assigned to a user, a particular permission they have (by virtue of their roles), or by their status (if their account is active or blocked). This is managed from the SHOW ONLY USERS WHERE panel:
Creating a user
Within the People area, there is a link Add user, which will allow us to create a new user account for our site:
This takes us to the new user page where we are required to fill out the Username, E-mail address, and Password (twice to confirm) for the new user account we wish to create. We can also select the status of the user (Active or Blocked), any roles we wish to apply to their account, and indicate if we want to automatically e-mail the user to notify them of their new account:
Editing a user
To edit a user account we simply need to click the edit link displayed next to the user in the user list. This takes us to a page similar to the create user screen, except that it is pre-populated with the users details. It also contains a few other settings related to some default installed modules. As we install new modules, the page may include more options.
Inform the user!
If you are planning to change a user’s username, password, or e-mail address you should notify them of the change, otherwise they may struggle the next time they try to log in!
Suspending / blocking a user
If we need to block or suspend a user, we can do this from the edit screen by updating their status to Blocked:
This would prevent the user from accessing our site. For example, if a user had been posting inappropriate material, even after a number of warnings, we could block their account to prevent them from accessing the site.
Why block? Why not just delete?
If we were to simply delete a user who was troublesome on the site, they could simply sign up again (unless we went to a separate area and also blocked their e-mail address and username). Of course, the user could still sign up again using a different e-mail address and a different username, but this helps us keep things under control.
Canceling and deleting a user account
Also within the edit screen is the option to cancel a user’s account:
On clicking the Cancel account button, we are given a number of options for how we wish to cancel the account:
The first and third options will at least keep the context of any discussions or contributions to which the user was involved with. The second option will unpublish their content, so if for example comments or pages are removed which have an impact on the community, we can at least re-enable them. The final option will delete the account and all content associated with it.
Finally, we can also select if the user themselves must confirm that they wish to have their account deleted. Particularly useful if this is in response to a request from the user to delete all of their data, they can be given a final chance to change their mind.
Bulk user operations
For occasions when we need to perform specific operations to a range of user accounts (for example, unblocking a number of users, or adding / removing roles from specific users) we can use the Update options panel, in the user list to do these:
From here we simply select the users we want to apply an action to, and then select one of the following options from the UPDATE OPTIONS list:
- Unblock the selected users
- Block the selected users
- Cancel the selected user accounts
- Add a role to the selected users
- Remove a role from the selected users
Users are grouped into a number of roles, which in turn have permissions assigned to them. By default there are three roles within Drupal:
- Anonymous users
- Authenticated users
The anonymous and authenticated roles can be edited but they cannot be renamed or deleted. We can manage user roles by navigating to People | Permissions | Roles:
The edit permissions link allows us to edit the permissions associated with a specific role. To create a new role, we simply need to enter the name for the role in the text box provided and click the Add role button.