0

The custom role shop manager created by Woocommerce can only assign the customer role when adding a user.

I'm trying to let shop manager choose from the different roles by enabling the capability promote_users.

function shop_manager_add_users() {
    $role = get_role( 'shop_manager' );
    $role->add_cap( 'promote_users' );
}
add_action( 'admin_init', 'shop_manager_add_users');

It's not working, the selection drop down only offers the customer role, and other roles are still hidden.

Is there another capability that should be enabled?

koji
  • 1
  • 3

1 Answers1

0

Actually Woocommerce adds specific restrictions to the Shop Manager role.

This worked and allowed a consigner custom role to be available in the dropdown :

function shop_manager_role_edit_cap( $roles ) {
    $roles[] = 'consigner';
    return $roles;
}
add_filter( 'woocommerce_shop_manager_editable_roles', 'shop_manager_role_edit_cap' );

Source: developer.woocommerce.com/

koji
  • 1
  • 3