【发布时间】:2017-10-22 02:57:55
【问题描述】:
我想限制 wordpress 自定义角色只查看用户列表中的特定用户。
我创建了自定义角色(销售)。销售角色只能查看表格中的特定角色。
【问题讨论】:
标签: php wordpress woocommerce hook-woocommerce
我想限制 wordpress 自定义角色只查看用户列表中的特定用户。
我创建了自定义角色(销售)。销售角色只能查看表格中的特定角色。
【问题讨论】:
标签: php wordpress woocommerce hook-woocommerce
您需要使用以下逻辑将能力分配给销售角色,
function add_theme_caps() {
// gets the author role
$role = get_role( 'sales' );
// This only works, because it accesses the class instance.
// would allow the author to edit others' posts for current theme only
$role->add_cap( 'list_users' );
}
add_action( 'admin_init', 'add_theme_caps');
【讨论】: