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.
- 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.
- Installed a database backup plugin to backup database only. “All-in-One WP Migration and Backup” installation was also not allowed on wealthyaffiliate.com.
- Uploaded the fresh core files from WordPress and restored content files from the backup to the new host.
- Restored the database files to the new host’s phpMyAdmin.
- Did some necessary changes to the wp-config.php file for new database name and credentials.
- 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.
- I accessed the website root folder from SSH with the owner privilege.
- Entered the command
wp role list
to see all the available roles (in my case the Administrator role was missing). - Enter the command
wp role reset administrator
- 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.