You can get an issue while accessing your WordPress admin dashboard. Such a message would be, “Sorry, you are not allowed to access this page” when trying to log in, you know the feeling first hand.
You can fix this issue using several solutions and get back to your Wordpress admin page without wasting the much time.
There could be various causes of this error: a permission issue, incorrect information in the wp-config.php file, or an outdated PHP version. Here, we have mentioned a few solutions that might fix your issue. You can try it one by one.
1. Disable All the Plugins
Wordpress admin page error sorry, you are not allowed to access this page could be triggered after adding a new plugin or upgrade of an existing plugin. You can disable the plugins one by one. If the site starts working after the plugin update, you will need to troubleshoot the issue with the causing plugin or you can remove the same plugin if not required.
After deactivating the plugin, rename the plugin folder inside the plugins directory.
2. Activate a Default Theme
If you have just updated a Wordpress theme, that might be a potential cause of the same error. Activate the default theme for the website to give a check. If the error fixes, you will need to troubleshoot the newly updated plugin.
To disable the theme, you will need to connect FTP to your Wordpress and go to the wp-content > themes path and find the theme, giving an error and rename it.
3. Check Your Error Log and find Cause
It is always a good idea to check the error log to troubleshoot the issue. Inside Wordpress you will find a file called error.log file. Here, you may find the exact issue which causes the error. You may find an incompatible plugin or theme which may cause the issue. Troubleshoot the error that you have found in the error.log file and that will fix your issue.
4. Ensure That Your Database Prefix Is Correct
Each MySQL database contains a prefix. You will need to check the MySQL tables and verify them in the wp.config.php file both should be similar. Inside wp.config.php, you will find an option $table_prefix = 'your table prefix'. If these both don't match, you may receive the "Sorry, you are not allowed to access this page" error.
Please refer to How to change Wordpress database table prefix for more details.
5. Your user should be the administrator
You will need to make sure that the user with which you are trying to log in as administrator or else you will receive the same error. To verify the user access the phpMyAdmin and check for the wp_user table and get the username and user_id.
Now, go to the wp_usermeta table and check for the wp_capabilities.
If your meta value is showing other than above, you can change it by clicking on the edit button. Also, you can create another Wordpress admin user from phpMyAdmin as well.
6. Verify if there are any changes in wp-config.php File
You will need to identify if there are any changes to your Wordpress wp-config.php file. You can connect to FTP and find out if there are any changes. You can verify the wp-config.php file to fix your issue.
7. Change to the latest PHP version
An irrelevant PHP version to your Wordpress may be the source of the same issue. You can try to upgrade your PHP version to fix the error.
Please refer to How to change PHP version in cPanel for more details.
8. Check for the File Permissions
If Wordpres files/folders permission is changed, you may receive such an error though your user is an administrator. Wordpress will consider it unauthorized to login. You will need to check the folder permission such as public_html, wp-admin, wp-content and wp-includes. If you are using the cPanel, all the folder permission should be 755 and file permission should be 644.
Please refer to How to change file permission in cPanel for more details.