如何将编辑用户权能添加到自定义角色?

时间:2015-11-20 作者:Nikhil

下面是我添加的代码,它为自定义角色提供了“edit\\u users”功能。

function edit_shop_manager() {
    // Get custom role
    $shop_manager = get_role(\'shop_manager\');
    $shop_manager->add_cap(\'create_users\');
    $shop_manager->add_cap(\'edit_users\');
    $shop_manager->add_cap(\'delete_users\');
    $shop_manager->add_cap(\'list_users\');
    $shop_manager->add_cap(\'remove_users\');
    $shop_manager->add_cap(\'promote_users\');
}
add_action( \'init\', \'edit_shop_manager\' );
当我在函数中添加此代码时。php,用户部分对角色为“shop\\u manager”的用户可见。但“编辑用户”选项不可用。

代码有问题吗?

1 个回复
SO网友:Capiedge

在你在multisite 安装是否尝试添加“manage\\u network\\u users”功能?

function edit_shop_manager() {
    // Get custom role
    $shop_manager = get_role(\'shop_manager\');
    $shop_manager->add_cap(\'create_users\');
    $shop_manager->add_cap(\'edit_users\');
    $shop_manager->add_cap(\'manage_network_users\');
    $shop_manager->add_cap(\'delete_users\');
    $shop_manager->add_cap(\'list_users\');
    $shop_manager->add_cap(\'remove_users\');
    $shop_manager->add_cap(\'promote_users\');
}
add_action( \'init\', \'edit_shop_manager\' );