Restrict the "Login as a User" functionality to certain User Roles

In order to limit or restrict the users that someone is able to log in as a user follow the steps below.

1. Install and Activate this plugin https://wordpress.org/plugins/user-role-editor/

2. Admin > Users > User Role Editor

3. Add Role > 

Role name (ID): LoginAsUserAdmin
Display Role Name: LoginAsUserAdmin
Make copy of: Administrator

Click on the button "Add Role".

4. Select the Role you've cretated "LoginAsUserAdmin", and uncheck all capabilities, then check only two capabilities, the Edit users and the List users, and click on the Update button.

Now when a user has the capability "LoginAsUserAdmin" he will be able to login as any user.

Note that if you don't check the Edit users capability, the user will not be able to login as a user.

6. Create a user from Admin > Users > Add new and give "LoginAsUserAdmin" capability.

Now the user "admin" can login as any user.

That's all :)

Feel free to contact us if you need any help.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.