I encountered an error lately after migrating one of my client’s website, which said that “Sorry, you are not allowed to access this page“. Strange! because all the core and database files were intact.

So, there is this website wealthyaffiliate.com which offers its clients to instantiate WordPress installation. Worse thing about them is that they do not offer File Manager, phpMyAdmin for the traditional backup route. They offer FTP access though and again disallow some popular WordPress plugins which are handy in taking website backups.

Here are the steps which I took before encountering this error.

  1. I took backup of the whole website’s core files from FTP access, which took a lot of time as there were roughly around 18,000 files and folders.
  2. Installed a database backup plugin to backup database only. “All-in-One WP Migration and Backup” installation was also not allowed on wealthyaffiliate.com.
  3. Uploaded the fresh core files from WordPress and restored content files from the backup to the new host.
  4. Restored the database files to the new host’s phpMyAdmin.
  5. Did some necessary changes to the wp-config.php file for new database name and credentials.
  6. After all set, When I accessed the website/wp-admin.php page, it threw the error of “Sorry, you are not allowed to access this page“.

There are plenty of websites out there who are guiding to get rid of this error by beating around the bush. But my workaround gave me a solution which is about the roles associated with the admin user.

While taking the backup of database, wealthyaffiliate.com somehow manipulated the core roles of WordPress and deleted the Administrator role. In fact, when I checked the roles, there were only two roles left, contributor and subscriber.

Here are the steps which I took to resolve this error.

  1. I accessed the website root folder from SSH with the owner privilege.
  2. Entered the command wp role list to see all the available roles (in my case the Administrator role was missing).
  3. Enter the command wp role reset administrator
  4. Now enter the command wp user set-role 1 administrator

That is it. Not you should be able to login to your admin panel without any error.

Source of this solution is here.

Leave a Reply

Your email address will not be published. Required fields are marked *

HTML Snippets Powered By : XYZScripts.com