1. Home
  2. Applications Management
  3. WordPress
  4. “Sorry, You Are Not Allowed to Access This Page” Error in WordPress? Here’s How to Fix It!

“Sorry, You Are Not Allowed to Access This Page” Error in WordPress? Here’s How to Fix It!

While trying to access your WordPress admin panel, you may be encountering the “Sorry, you are not allowed to access this page” error. This error will be preventing you from accessing your dashboard and making important changes on your site.

What Causes the “Sorry, You Are Not Allowed to Access This Page” Error

Fundamentally, this error occurs as a result of a username role issue. To be more specific, the username that you were using to access your WordPress dashboard, doesn’t have an administrator role.

How to Fix the “Sorry, You Are Not Allowed to Access This Page” Error for WordPress Dashboard

Before going further, it’s highly recommended that you back up your WordPress database. This will ensure that you can easily restore your database in case something goes wrong while troubleshooting this issue. 

In order to fix the aforementioned error, you’ll need to set administrator role to your WordPress admin panel username. You can easily do so using phpMyAdmin or WP-CLI, which is the command-line interface for WordPress. We’ll explore both options.

How to change WordPress user roles in MySQL database using PhpMyAdmin?

We’ll assume that you’re already logged into your phpMyAdmin.

1) You’ll have to locate first the ID number for your WordPress admin username. Open the wp_users or xxx_users table in the database as highlighted. (wp_ is just the prefix, your table prefix may be different)

2) Once you’ll open the wp_users table, you will see a list with the existing usernames which are created on your WordPress site. Locate the username that you were using to log in as an admin and look up after the ID. In our case, the ID is “1” as can be seen in the screenshot below.

3) Now that we know the ID for the admin username, the next thing to do is to open the wp_usermeta or xxx_usermeta table in the database as highlighted. (wp_ is just the prefix, your table prefix may be different)

4) In the wp_usermeta table, you can find wp_capabilities under meta_key column.

If the meta_value is empty, you will need to add the following value:

a:1:{s:13:"administrator";b:1;}

The roles are saved in the form of a serialized PHP array. Change the user role you want to assign to the current user by changing the meta_value as:

Administrator
a:1:{s:13:"administrator";b:1;}

Subscriber
a:1:{s:10:"subscriber";b:1;}

Contributor
a:1:{s:11:"contributor";b:1;}

Author
a:1:{s:6:"author";b:1;}

Editor
a:1:{s:6:"editor";b:1;}

That’s it, now that you’ve added administrator role to your username, you should clear the cache and cookies for your web browser and try again to log in.

How to change WordPress user roles in MySQL database using WP-CLI

This tutorial assumes that your web hosting provides you with access to WP-CLI which is the WordPress command-line interface for your WordPress website.

Don’t forget that ChemiCloud’s infrastructure supports WP-CLI out of the box. If you’d like to experience top speed and reliability and have access to great tools like WP-CLI, try our WordPress hosting

1) Once you’ve accessed WP-CLI via SSH, navigate to the directory where your WordPress site is installed.

2) You’ll have to locate first the ID number for your WordPress admin username by using the following command line:

wp user list

This command will display all the existing usernames and the role for each:

+—-+————+————–+———————–+———————+—————+
| ID | user_login | display_name | user_email | user_registered | roles |
+—-+————+————–+———————–+———————+—————+
| 1 | cch | cch | admin@chemiccloud.com | 2019-07-24 11:06:17 |
+—-+————+————–+———————–+———————+—————+

As you can see, the role of our username is missing.

3) The next step is to change the role of our username, which is using “1” as the ID, as can be seen in the first column. The command line that we’ll use is:

wp user set-role 1 administrator

Success: Added cch (1) as administrator.

This command will attribute an administrator role to the username.

Available WordPress users roles:

  • administrator
  • editor
  • author
  • contributor
  • subscriber

That’s it, now that you’ve added administrator role to your username, you should clear the cache and cookies for your web browser and try again to log in.

Troubleshooting WordPress issues is easy when you have the right WordPress hosting provider by your side. If you’d like to experience top speed and have access to our amazing WordPress Experts, try our WordPress Hosting. We’ll move your existing site in less than one hour without any interruption. It is included FREE with purchase of any WordPress hosting plan.

Updated on July 24, 2019

Was this article helpful?

Related Articles

Need help?
We're always here for you. Submit a ticket or Chat with a live person.
Submit Ticket