Add WooCommerce Shop Manager custom role for Advanced Post Types Order sorts

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

As described at Filter – Add Custom Role / Modify exiting – Minimum capability to use this plugin custom role can be appended to the existing list. This is not something to be included automatically, as custom roles rely on capabilities, so it needs one to select.

For WooCommerce there’s a Shop Manager custom role. To add this role in the list we can use the following code:

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['Shop Manager'] = array(
                                            'title'         =>  __('Shop Manager', '_my_localize_prefix_'),
                                            'capability'    =>  'delete_products');

            return $roles_capability;

As a capability, we use the ‘delete_products‘ which is also available for Administrator. The shop_manager capability is available only for Shop Manager role, if used instead, the administrator will no longer see the sort since it does not include such capability.