I just disabled all plugins, and then upgraded my WP to 4.7.3
. And then first thing i do is to login as Administrator to the Panel.
Then i'm getting:
Sorry, you are not allowed to access this page
( Note: My Wordpress is using the default prefix wp_
, so it shouldn't be the prefix issue. )
Then i did a bit of manual debugging. Here are steps:
(1) Inside wp-includes/user.php
, after line 104
, put print_r( $user ); exit;
before the last line inside function wp_signon( )
. And it returns the VALID user object which is correct:
104: do_action( 'wp_login', $user->user_login, $user );
105: print_r( $user ); exit;
106: return $user;
107: }
WP_User Object ( [data] => stdClass Object ( [ID] => 1 [user_login] => admin [user_pass] => $Q$BipvC2ydjzFlGFKbY.JKJhPqbEU7Ue. [user_nicename] => admin [user_email] => [email protected] [user_url] => [user_registered] => 2013-08-05 06:46:16 [user_activation_key] => [user_status] => 1 [display_name] => Administrator ) [ID] => 1 [caps] => Array ( [administrator] => 1 ) [cap_key] => wp_capabilities [roles] => Array ( [0] => administrator ) [allcaps] => Array ( [switch_themes] => 1 [edit_themes] => 1 [activate_plugins] => 1 [edit_plugins] => 1 [edit_users] => 1 [edit_files] => 1 [manage_options] => 1 [moderate_comments] = .................
( That means, at this point, Wordpress can properly authenticate the user and retrieve it's Object. So nothing is wrong with authentication part! )
(2) Then, inside wp-admin/admin.php
, after line 31
, put the echo get_current_user_id();
31: require_once(dirname(dirname(__FILE__)) . '/wp-load.php');
32: echo get_current_user_id();
Then, here it comes!
0
Sorry, you are not allowed to access this page.
So that means, at this point, the logged in Admin User just now has gone. Wordpress has lost the User, and hence is not remembering the user.
Can anyone help me understand to solve WHY is that happening please?
In case you want to know, here are my Database values, inside wp_usermeta
table (for user_id=1
):
wp_capabilities = a:1:{s:13:"administrator";s:1:"1";}
wp_user_level = 10
is_user_logged_in()
return true on the front end vs the admin area if you hook it viainit
?1
. (Thanks for helping out! :))wp_get_current_user()
to find different details as well. developer.wordpress.org/reference/functions/get_current_user_id/… If you're really curious about pinpointing the problem, this may help. Although because you have been editing core files, I think the answer I've provided below is the best option to restore your site to function properly again.