WordPress的权限是个好东西。但是今天一不小心把所有的权限都删除了。意思就是:
任何账号都不能登陆后台了。
解决方法:
可以通过在主题的functions.php里添加管理员权限。
提示一点:下面的代码先删除了管理员权限,再添加的管理员权限。
这是为了避免新添加的权限无法覆盖现有的管理员权限。如果使用下面的代码之前,自己试着添加过一些管理员权限,那么需要先清除。
if (get_role('administrator')) { remove_role('administrator'); } if (!get_role('administrator')) { add_role( 'administrator', 'Administrator', array( 'create_sites' => true, 'delete_sites' => true, 'manage_network' => true, 'manage_sites' => true, 'manage_network_users' => true, 'manage_network_plugins' => true, 'manage_network_themes' => true, 'manage_network_options' => true, 'upload_plugins' => true, 'upload_themes' => true, 'upgrade_network' => true, 'setup_network' => true, 'activate_plugins' => true, 'create_users' => true, 'delete_plugins' => true, 'delete_themes' => true, 'delete_users' => true, 'edit_files' => true, 'edit_plugins' => true, 'edit_theme_options' => true, 'edit_themes' => true, 'edit_users' => true, 'export' => true, 'import' => true, 'install_plugins' => true, 'install_themes' => true, 'list_users' => true, 'manage_options' => true, 'promote_users' => true, 'remove_users' => true, 'switch_themes' => true, 'update_core' => true, 'update_plugins' => true, 'update_themes' => true, 'edit_dashboard' => true, 'customize' => true, 'delete_site' => true, 'moderate_comments' => true, 'manage_categories' => true, 'manage_links' => true, 'edit_others_posts' => true, 'edit_pages' => true, 'edit_others_pages' => true, 'edit_published_pages' => true, 'publish_pages' => true, 'delete_pages' => true, 'delete_others_pages' => true, 'delete_published_pages' => true, 'delete_others_posts' => true, 'delete_private_posts' => true, 'edit_private_posts' => true, 'read_private_posts' => true, 'delete_private_pages' => true, 'edit_private_pages' => true, 'read_private_pages' => true, 'unfiltered_html' => true, 'unfiltered_upload' => true, 'edit_published_posts' => true, 'upload_files' => true, 'publish_posts' => true, 'delete_published_posts' => true, 'create_posts' => true, 'edit_posts' => true, 'delete_posts' => true, 'read' => true, ) ); }
这样,管理员权限是回来了。记住,权限回来了,就将上面的代码删除,不要留在functions.php里。否则会影响权限相关插件的使用,尤其User Role Editor。
评论区
发表新的留言
您可以留言提出您的疑问或建议。
您的留言得到回复时,会通过您填写的邮箱提醒您。