Filter – Add Custom Role / Modify exiting – Minimum capability to use this plugin

Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInPrint this page


This filter can be used to add a Custom Role or to Modify existing role capability. The minimum capability setting is used to show the re-order interface to certain roles.

apto_get_roles_capability

Examples

The following code will add a custom role also modify the Subscriber role capability to something else:

add_filter('apto/get_roles_capability', 'theme_apto_get_roles_capability');
function theme_apto_get_roles_capability($roles_capability)
    {
        //add a custom role 
        $roles_capability['Custom Role'] = array(
                                        'title'         =>  __('Custom Role', '_my_localize_prefix_'),
                                        'capability'    =>  'read');
        
	//modify the custom capability
        $roles_capability['Subscriber']['capability']   =  'custom_capability';
            
        return $roles_capability;
    }

*This code should be used within a theme or a custom plugin.

API Index


Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Istofazse

Hi,
In the case i want to set shop manager role the capacity to re-order, i need to change ‘Custom Role’ to ‘Shop Manager’ ?

nspcode

Hi,
Yes this is correct. You may want to check with this article as it explain exactly on how to do that. https://www.nsp-code.com/add-woocommerce-shop-manager-custom-role-for-advanced-post-types-order-sorts/