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 append to existing list. This is not something to be included automatically, as custom roles rely on capabilities, so it need one to selected.

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 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.


  • Istofazse

    Hi,
    I have inserted this code on my wp installation but cant make it work, (i am using a plugin called snippets to add filters as external code – so its theme upgrade proof) can this be the reason is not working? If that’s the case were do you recommend inserting it?
    Thanks

    • nspcode

      Hi,
      You should add the code within your theme (child theme if apply) functions.php file

      Thanks

      • Istofazse

        Hi,
        I have done so and the result is the same, it does not work!

        Meanwhile i have been wondering around because i had the ideia i already seen an option to alow re-order somewere…

        And indeed, in the free version of the plugin there is a field inside settings>post type orders that lets you define the role users must have to use the tool, and it works… (in my case if i define the user that can use the RE-ORDER as > Editor, then the Shop Manager role is able to do so)

        Question: Can you update the paid version so it incorporates that feature of the free version?

        Thanks

        • nspcode

          Hi,
          Can you get in touch with us through contact with a login details to your site and i’ll check into this. The advanced version contain additional filters and actions which help to customize that area, the free plugin use a basic solution.

          Thanks