Not able to access WP Admin, it says “Sorry, you are not allowed to access this page.”

I managed to solve this.

Reason was that: The data about user roles, that’s set by default in a WordPress installation was completely missing in the db table wp_options under the wp_user_roles row.

In my case it was this

a:3:{s:14:"backwpup_admin";a:2:{s:4:"name";s:14:"BackWPup Admin";s:12:"capabilities";a:12:{s:4:"read";b:1;s:8:"backwpup";b:1;s:13:"backwpup_jobs";b:1;s:18:"backwpup_jobs_edit";b:1;s:19:"backwpup_jobs_start";b:1;s:16:"backwpup_backups";b:1;s:25:"backwpup_backups_download";b:1;s:23:"backwpup_backups_delete";b:1;s:13:"backwpup_logs";b:1;s:20:"backwpup_logs_delete";b:1;s:17:"backwpup_settings";b:1;s:16:"backwpup_restore";b:1;}}s:14:"backwpup_check";a:2:{s:4:"name";s:21:"BackWPup jobs checker";s:12:"capabilities";a:12:{s:4:"read";b:1;s:8:"backwpup";b:1;s:13:"backwpup_jobs";b:1;s:18:"backwpup_jobs_edit";b:0;s:19:"backwpup_jobs_start";b:0;s:16:"backwpup_backups";b:1;s:25:"backwpup_backups_download";b:0;s:23:"backwpup_backups_delete";b:0;s:13:"backwpup_logs";b:1;s:20:"backwpup_logs_delete";b:0;s:17:"backwpup_settings";b:0;s:16:"backwpup_restore";b:0;}}s:15:"backwpup_helper";a:2:{s:4:"name";s:23:"BackWPup jobs functions";s:12:"capabilities";a:12:{s:4:"read";b:1;s:8:"backwpup";b:1;s:13:"backwpup_jobs";b:1;s:18:"backwpup_jobs_edit";b:0;s:19:"backwpup_jobs_start";b:1;s:16:"backwpup_backups";b:1;s:25:"backwpup_backups_download";b:1;s:23:"backwpup_backups_delete";b:1;s:13:"backwpup_logs";b:1;s:20:"backwpup_logs_delete";b:1;s:17:"backwpup_settings";b:0;s:16:"backwpup_restore";b:0;}}}

Whereas it should have Administrator at least somewhere. And this missing data in the database caused the WordPress system to behave weird (actually working just as expected in the scenario of the missing data)

I knew what it should look like but to test it what I did was got the wp_user_roles from another WP site I manage and pasted it in the field in the table and saved and baam! The site opened.

Now why this happened all of a sudden?

Well in my case it seems like there had been some sort of breach, an attack, because now that I am in the dashboard the first I did was I went to the user’s page and there’s a bazillion strange user accounts.

So I have got another job to do now that is to find out the cause and clean the mess up but for anyone having troubles figuring out problems with accessing the WP admin page and see the error message, and nothing works, like disabling plugins etc then do take a look at the actual database fields whether it is in line or not. I was able to pinpoint that by using simply print_ring the user object and noticed there were no roles, then I used methods to add the Administrator role and it simply didn’t add to it, and then I figured that the role Administrator is missing itself.