自定义用户角色不应用更改

时间:2015-09-04 作者:Interactive

我创建了一个自定义用户角色,但发生了一些奇怪的事情。

这就是角色:

add_role(\'custom-role\', \'Custom Role\', array(
\'activate_plugins\' => false,
\'delete_others_pages\' => true,
\'delete_others_posts\' => false,
\'delete_pages\' => true,
\'delete_posts\' => false,
\'delete_private_pages\' => true,
\'delete_private_posts\' => false,
\'delete_published_pages\' => true,
\'delete_published_posts\' => false,
\'edit_dashboard\' => false,
\'edit_others_pages\' => false,
\'edit_others_posts\' => false,
\'edit_pages\' => true,
\'edit_posts\' => false,
\'edit_private_pages\' => true,
\'edit_private_posts\' => false,
\'edit_published_pages\' => true,
\'edit_published_posts\' => false,
\'edit_theme_options\' => false,
\'export\' => false,
\'import\' => false,
\'list_users\' => true,
\'manage_categories\' => false,
\'manage_links\' => false,
\'manage_options\' => false,
\'moderate_comments\' => false,
\'promote_users\' => false,
\'publish_pages\' => true,
\'publish_posts\' => false,
\'read_private_pages\' => false,
\'read_private_posts\' => false,
\'read\' => false,
\'remove_users\' => true,
\'switch_themes\' => false,
\'upload_files\' => true,
\'update_core\' => false,
\'update_plugins\' => false,
\'update_themes\' => false,
\'install_plugins\' => false,
\'install_themes\' => false,
\'delete_themes\' => false,
\'delete_plugins\' => false,
\'edit_plugins\' => false,
\'edit_theme\' => false,
\'edit_files\' => false,
\'edit_users\' => true,
\'create_users\' => true,
\'delete_users\' => true,
\'unfiltered_html\' => false
));
这一点也不奇怪。但问题是,首先我将所有值设置为false.如果我使用所选角色登录用户,则会显示Dashboard, posts, reactions, profileextra.

问题是,如果我将值从falsetrue 没有任何变化
我已注销和登录,删除了我的Cookie并删除了缓存。

我不知道怎么解决这个问题。

1 个回复
SO网友:Maikal

在WP文件中:

NB: This setting is saved to the database (in table wp_options, field wp_user_roles), so it might be better to run this on theme/plugin activation

这意味着当你第一次运行你的代码时saved to db, 如果你再试一次,它就不会改变,因为它已经在DB中了。。你应该remove role 进行更改之前。。