Wordpress 仪表板:"Sorry you are not allowed to access this page" 将实时网站移动到本地主机后
Wordpress dashboard : "Sorry you are not allowed to access this page" after moving live website to localhost
我尝试手动备份我的 Wordpress 网站。
- 我备份了我的 htdocs 文件夹。
- 我导出了我的数据库的 .sql 文件备份,它以“mas”作为前缀。 (后面没有下划线)
- 我在我的所有数据库(使用 PowerShell)中为新的 URL 更新了旧的 URL。
- 我更新了 wp-config.php 文件。
- 我在我的本地主机服务器上创建了一个同名的新数据库。
- 我在 PhpMyAdmin 上导入了 .sql 文件。
之后,我意识到我无法以管理员身份访问仪表板。
我收到以下消息:Désolé,vous n’avez pas l’autorisation d’accéder à cette page。
在法语中相当于:抱歉,您不能访问此页面。
所以我停用了所有插件。
我将 .htaccess 文件更改为 .htaccess.old .
在我的数据库中,我的 table usermeta 是为我的用户帐户配置的。出于某种原因,我有两次“prefix_capabilites”和“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
然后,我尝试用 PHPStorm 调试我的网站。
这是我发现的:
// 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.
}
然后,它 returns 在这里 :
// 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.
}
因此,据我了解,我的页面 index.php 对于 table $_wp_menu_nopriv[].
被认为是正确的
并且它在某种程度上证实了用户无法访问管理页面。
但是我不明白这个变量 $_wp_menu_nopriv[] 是什么意思?
你能帮帮我吗?
更新 1:
我试图将我的用户 wp_capabilites 值更改为:
'a:1:{s:13:"administrator";s:1:"1";}'
但是也没用。
当我尝试使用备份插件备份我的站点时,有时总会出现错误。
更新 2:
我从这个 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.
您可以尝试更改 wp_capalities
update wp_usermeta
set meta_value = 'a:1:{s:13:"administrator";s:1:"1";}'
where user_id = YOUR USER ID
and meta_key = 'wp_capabilities';
否则你可以考虑安装一个全新的 wordpress 并使用插件迁移:https://wordpress.org/plugins/all-in-one-wp-migration/
我从另一个 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.
我尝试手动备份我的 Wordpress 网站。
- 我备份了我的 htdocs 文件夹。
- 我导出了我的数据库的 .sql 文件备份,它以“mas”作为前缀。 (后面没有下划线)
- 我在我的所有数据库(使用 PowerShell)中为新的 URL 更新了旧的 URL。
- 我更新了 wp-config.php 文件。
- 我在我的本地主机服务器上创建了一个同名的新数据库。
- 我在 PhpMyAdmin 上导入了 .sql 文件。
之后,我意识到我无法以管理员身份访问仪表板。
我收到以下消息:Désolé,vous n’avez pas l’autorisation d’accéder à cette page。
在法语中相当于:抱歉,您不能访问此页面。
所以我停用了所有插件。 我将 .htaccess 文件更改为 .htaccess.old .
在我的数据库中,我的 table usermeta 是为我的用户帐户配置的。出于某种原因,我有两次“prefix_capabilites”和“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 |
然后,我尝试用 PHPStorm 调试我的网站。
这是我发现的:
// 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.
}
然后,它 returns 在这里 :
// 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.
}
因此,据我了解,我的页面 index.php 对于 table $_wp_menu_nopriv[].
被认为是正确的并且它在某种程度上证实了用户无法访问管理页面。
但是我不明白这个变量 $_wp_menu_nopriv[] 是什么意思?
你能帮帮我吗?
更新 1:
我试图将我的用户 wp_capabilites 值更改为: 'a:1:{s:13:"administrator";s:1:"1";}'
但是也没用。
当我尝试使用备份插件备份我的站点时,有时总会出现错误。
更新 2:
我从这个 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.
您可以尝试更改 wp_capalities
update wp_usermeta
set meta_value = 'a:1:{s:13:"administrator";s:1:"1";}'
where user_id = YOUR USER ID
and meta_key = 'wp_capabilities';
否则你可以考虑安装一个全新的 wordpress 并使用插件迁移:https://wordpress.org/plugins/all-in-one-wp-migration/
我从另一个 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.