Change Accounts with the Masquerade Drupal Module
Do you need to check what your users see when they login to your site? Do you often need to troubleshoot issues for your users? If so, the Masquerade module will be a very useful tool.
The Masquerade module allows you to login as any user but using your own password. You can mimic anyone else’s login and see exactly what they see. This is very useful on membership sites and sites that require multiple levels of access.
Step 1. Download and install
- Download the module from http://drupal.org/project/masquerade.
- Click Browse to find the downloaded module on your computer.
- Click Install.
Step 2. Activate and configure
- Click the checkbox.
- Scroll to the bottom of the page and click Save Configuration. You will see the Permissions and Configure links.
- Click Configure.
Step 3. Roles and Users
- Choose “administrator”. Any roles can be used for masquerading but it is safer to restrict this to adminstrators only.
- If you want to test on particularly user often, add their username here. Their name will appear as a menu link.
- If you want to test on particularly user often, add their username here. Their name will appear in the Masquerade block.
- Click Save Configuration.
One way to use this efficiently is to create a test user for each role. So you might create a test account for the anonymous user role and another for the authenticated user role. You can then enter the names of the test users into 2 and 3.
Step 4. Give the administrator permission to use Masquerade
- Go back to the Module Page and click on Permissions.
- Click the checkboxes to allow administrator access to Masquerade.
- Scroll to the bottom of the page and Save Permissions.
Step 5. Create a block for quick access to user switching
Go to Structure > Blocks.
Find the Masquerade block in the disabled list and choose the region you want to place it in. I am going to put it Sidebar first for this lesson.
- Click Configure on the right side of the Masquerade row, Under Visibility settings.
- Click Pages and configure.
- Click Content types. Leave the checkboxes blank for no restrictions, or choose where you might want it.
- Check the box next to Administrator on the Roles panel.
- Click Save Block.
Step 6. Test the function of the module from the front end
- Go to your home page. On the front end you’ll see the Masquerade block.
- Type in a username and click Go and you will now be logged in as that user.
- If you filled in the Quick Switch Menu and Block user fields in Step 4, you’ll see quick links for logging in as admin and the test users.
- Click the link to one of your test users, and see what happens.
You’ll get a message that you are now masquerading as the test user.
There will be a link on the Navigation menu “Switch back” Click it and you will be back to the administrator user.
Notice that since you are now logged in as testone, you cannot see the Masquerade block, since we only gave access to administrators to see that. When you switch back it will be there again.
Click Log out.
You will now be viewing as an anonymous user.
We’re getting Access denied because we turned off all permissions for anonymous users, which may be what you want. Probably, though you want some things visible for anonymous users, and some special content visible only to registered users or whatever roles you created. Once you understand this process, you can go back and configure your desired permissions.
In this demo we have three very distinct user experiences and its easy to see exactly what each user role is allowed to see.
Step 7. Alternate access to user switching
Go to People and click the name of a user from the list view.
Note: If you want to only use this method, you do not need to create a Masquerade block.
1. You will now see a link on the user History that says, “Masquerade as username“
2. If you filled in the field titled “Menu Quick Switch User” in Step 4, you will see a link in the Navigation block that lets you switch to whatever user you specified there. If you left that blank, it will just say “Switch back”. and you will switch back to the administrator.
Now you have all the basics. It should make it easier to set up complicated user access control. If you’re a beginner it would be a great idea to set up test users for each role and experiment with this.
Thanks a lot for this nice tutorial!! I wish I would have find it before… :))
thank You very much
Great tutorial; thank you! The missing step for me (i.e., the frustrating step that wouldn’t let me “switch back”): the Navigation menu needs to be active!