User Switching

Advertisement

Table of Content

Overview Overview

In this article, we are going to see how to use the User Switching WordPress plugin. We can test our current plugin or theme for different user roles.

Top ↑

Create User Create User

We need to create a new user. You can create from Users > Add new page.

But, I am using WP CLI command wp user create to create the test users.

Note: You can skip the user creating process from the WP CLI command.

Okay. So, lets create test-editor user with editor role.

wp user create test-editor editor@example.com --role=editor --user_pass=12345

Here, Our test-editor user is created with editor user role & with password 12345.

Read more about how to create multiple user roles for testing the purpose?

Top ↑

How to Switch User? How to Switch User?

Goto Users page to see all existing users. You can see the Switch To link for each of the user.

See below screenshot for the reference.

Now, On click on that user you can see how the WordPress dashboard looks like for the editor user role.

Real life example.

I have created a plugin Free Images WordPress plugin. We can download royalty-free images from 1.7 million images library from the Pixabay.

In this plugin there was the user role issue in which editor was not able to see the Download Images menu.

While registering the Download Images page I have used manage_options user permissions. Which should be upload_files.

After fixing the issue I have created a test-editor user with editor user role.

And test the menu is available for the editor user by stitching to the test-editor user.

The page is now available for the editor user role too. See below screenshot for reference.

How to test the WordPress Plugin or Theme for different user roles with User Switching plugin.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: