最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

capabilities - How can I add capability to multiple roles?

programmeradmin1浏览0评论

I have this variable:

$wpll_accesslist = self::$options['wpll_settings']['wpll_accesslist'];

and it's output is:

Array
(
    [Author] => 1
    [Contributor] => 1
    [Shop_Manager] => 1
    [Customer] => 1
)

These Author, Contributor, Shop_Manager, Customer is roles. Now, I want to add new capability called wpll_caps to these roles.

What I am doing for this:

foreach($wpll_accesslist as $key => $value) {
    // get the the role object
    $role_object = get_role( strtolower($key) );
    // add wpll_caps capability to this role object
    $role_object->add_cap( 'wpll_caps' );
}

but it's not working. Am I missing something?

发布评论

评论列表(0)

  1. 暂无评论