【问题标题】:How to show custom users in the user table wordpress admin?如何在用户表 wordpress admin 中显示自定义用户?
【发布时间】:2017-10-22 02:57:55
【问题描述】:

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

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

【问题讨论】:

    标签: php wordpress woocommerce hook-woocommerce


    【解决方案1】:

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

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

    【讨论】:

    猜你喜欢
    • 2018-09-23
    • 2021-07-30
    • 2016-11-13
    • 2019-03-25
    • 1970-01-01
    • 1970-01-01
    • 2014-05-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多