Php 如何在用户表wordpress admin中显示自定义用户?

Php 如何在用户表wordpress admin中显示自定义用户?,php,wordpress,woocommerce,hook-woocommerce,Php,Wordpress,Woocommerce,Hook Woocommerce,我想限制wordpress自定义角色只查看用户列表中的特定用户 我已经创建了自定义角色(销售)。销售角色只能查看表中的特定角色。您需要使用以下逻辑将功能分配给销售角色: function add_theme_caps() { // gets the author role $role = get_role( 'sales' ); // This only works, because it accesses the class instance. // woul

我想限制wordpress自定义角色只查看用户列表中的特定用户


我已经创建了自定义角色(销售)。销售角色只能查看表中的特定角色。

您需要使用以下逻辑将功能分配给销售角色:

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');

您需要为自定义角色创建自定义功能。我建议你使用:plugin