All of a sudden we are not able to get to the admin panel of the website. Once I log into /wp-login.php it redirects me to the homepage or /wp-admin (depending on whether I visited wp-admin in logged out state or not)
WordPress version: 5.6.2
When it does redirect to /wp-admin
I see:
"Sorry, you are not allowed to access this page."
My first guess was that someone (maybe another user with administrator access) changed the roles. That wasn't the case, I confirmed by looking at the database tables and the users had the wp_capabilities
that corresponded to being an admin.
Then I tried a bunch of other stuffs and none worked:
Created a new user using
wp_create_user
, added administrator capabilities, logged into that account from a private browsing window. Same.Went to the WordPress git repo searched for where "Sorry, you are not allowed to access this page." appeared, it did at many places so I added random string of text in some files to see exactly which one, it came from the file
wp-admin/includes/menu.php
in the last lines:if ( ! user_can_access_admin_page() ) {
I thought maybe
user_can_access_admin_page()
returned wrong information for some reason, so I used a page template to output some data like so
if ( current_user_can('administrator') ) {
echo "Yes, admin";
}
if ( user_can_access_admin_page() ) {
echo "Can access admin";
} else {
echo "Can't access admin";
}
Both returned true, yet the check on menu.php
fails. Not sure why.
Replaced wp-admin and wp-includes folder with fresh copies downloaded from Wordpress org.
Renamed the theme and plugin folders to rule out the problem coming from a plugin or theme. Not the case, it still was the same.
Checked the error log of Apache2 as well as enabled debugging log for WP to look for any related error, none found. Nothing special, all the usual PHP notices that I have seen before.
At one point I noticed the SSL certificate expired a month ago (problem started yesterday though) so just to be sure I renewed that as well, still the same.
Anybody who have an idea on what might be wrong would be a great help!