I tried to backup my Wordpress website manually.
After that, I realized I could not access the dashboard as an administrator.
I had the following message : Désolé, vous n’avez pas l’autorisation d’accéder à cette page.
Which is the French equivalent of : Sorry, you are not allowed to access this page.
So I deactivated all my plugins. I changed my .htaccess file for .htaccess.old .
In my database, my table usermeta is configured like this for my user account. For some reason, I have two times "prefix_capabilites" and "prefix_user_level" :
meta_key | meta_value |
---|---|
mascapabilites | a:1:{s:13:"administrator";b:1;} |
masuser_level | 10 |
wp_capabilities | a:1:{s:13:"administrator";b:1;} |
wp_user_level | 10 |
And then, I tried to debug my website with PHPStorm.
This is what I found :
// plugin.php
function user_can_access_admin_page() {
global $pagenow, $menu, $submenu, $_wp_menu_nopriv, $_wp_submenu_nopriv,
$plugin_page, $_registered_pages;
$parent = get_admin_page_parent();
// I omitted some functions here...
if ( empty( $parent ) ) { // $parent is empty ""
if ( isset( $_wp_menu_nopriv[ $pagenow ] ) ) { // $pagenow is "index.php"
return false; // It returns here.
}
And then, it returns here :
// menu.php
if ( ! user_can_access_admin_page() ) {
/**
* Fires when access to an admin page is denied.
*
* @since 2.5.0
*/
do_action( 'admin_page_access_denied' );
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); // And displays this.
}
So, from what I understand, my page index.php is considered TRUE for the table $_wp_menu_nopriv[].
And it somewhat confirms that the user can't access admin page.
But I don't understand what this variable $_wp_menu_nopriv[] means ?
Can you help me?
UPDATE 1:
I tried to change my user wp_capabilites value to : 'a:1:{s:13:"administrator";s:1:"1";}'
But it didn't work either.
And when I try to backup my site with a backup plugin, there is always an error at some point.
UPDATE 2:
I found the solution to my problem from this website.
This occurs when you have (at some point) changed the database prefix using a utility that also altered capability records in the database.
To repair it, make note of your current database prefix. The default is 'wp_' and for simplicity we're going to assume the target prefix is 'wp_'. If the database prefix you wish to use is different, make sure to replace all instances of 'wp_' with your new prefix.
Use phpMyAdmin in Plesk for the database and complete these searches (using LIKE %...%):
In the wp_options table, look for the option_name that ends with "user_roles" and change its prefix so it reads "wp_user_roles" In the wp_usermeta table, look for all entries that begin with the wrong prefix and replace the incorrect prefix with wp_ Now login or refresh the page and you should find your user permissions have returned.
I found the solution to my problem from another website :
This occurs when you have (at some point) changed the database prefix using a utility that also altered capability records in the database.
To repair it, make note of your current database prefix. The default is 'wp_' and for simplicity we're going to assume the target prefix is 'wp_'. If the database prefix you wish to use is different, make sure to replace all instances of 'wp_' with your new prefix.
Use phpMyAdmin in Plesk for the database and complete these searches (using LIKE %...%):
In the wp_options table, look for the option_name that ends with "user_roles" and change its prefix so it reads "wp_user_roles" In the wp_usermeta table, look for all entries that begin with the wrong prefix and replace the incorrect prefix with wp_ Now login or refresh the page and you should find your user permissions have returned.