If you’re the admin of a WordPress website, it can be very useful to impersonate another user. This way you can check if all the access rights for that user are set up correctly.
When you add new functionality to your website, you may want to test this functionality in another user’s account. Another example is if one of your users claims that certain functionality is not working. By impersonating that user, it’s easy to rule out any issues with their account or user rights.
Of course, you can manually log out and log in with someone else’s account. However, this means that you need to either know their password or reset it. This takes a lot of time and is not very efficient. In this article we’ll show you how to easily switch user accounts in WordPress.
How to impersonate another user in WordPress
Even though it can be very useful for a website administrator, impersonating other users is not default functionality in WordPress. By default, WordPress lets you create new users and assign a role for that user. When going to Settings > General in WordPress, you can also allow visitors to register for an account and choose a default user role for those users.
To be able to quickly switch users, I use a plugin called User Switching. This plugin also works with WordPress Multisite, BuddyPress and bbPress. After installing and activating the plugin, a new option is added to the Users > All Users screen in WordPress:
When hovering over a user, a “Switch To” link will be visible. When clicking that link, you will be logged in to that user’s account. Of course, this feature is only available for users that have the “Administrator” role in your WordPress install.
After switching between accounts, you will see a new notification in the top of your admin screen, allowing you to switch back to your own account instantly:
Just click the “Switch back” link to go back to your own user account.
The User Switching plugin also contains a “Switch Off” feature. By clicking the “Switch Off” link (in the top right of the WordPress toolbar), you’ll be logged out of WordPress, but you retain the ability to switch back to your account without having to manually log in to WordPress. It will remember you by storing an authentication cookie in your browser.
After you click “Switch Off” in the WordPress menu bar, you’ll be sent back to the front end of your website. However, in the very bottom of your screen a new link can be found:
Click this link and you will be logged back in to your WordPress website without having to re-enter your login credentials. This can be very useful for testing (e.g. you want to see what your website looks like for users that are not logged in). However, make sure to only use this feature on your own private computer, as it will allow anyone to login to your (Admin) account without using any form of authentication.