1. Home
  2. Knowledge Base
  3. WooCommerce Wholesale Prices Premium
  4. Backend
  5. How to Let Shop Managers Edit Users in WooCommerce

How to Let Shop Managers Edit Users in WooCommerce

Starting from WooCommerce version 3.4.6, a security fix was introduced that restricts Shop Managers from editing other users, except those with the Customer role.

This means that by default, Shop Managers cannot edit users who have wholesale roles created by plugins such as WooCommerce Wholesale Prices or Wholesale Prices Premium.

Suppose you’d like your Shop Managers to be able to edit (and promote) users with wholesale roles. In that case, you can easily enable this functionality by adding the following code to your site.

How to Enable Shop Managers to Edit Wholesale Users

Add the following snippet to your theme’s functions.php file, your child theme, or a custom plugin.

/**
 * Allow Shop Managers to edit and promote wholesale users.
 */
function wws_add_shop_manager_user_editing_capability() {
    $shop_manager = get_role('shop_manager');

    if ( ! $shop_manager ) {
        return;
    }

    // Only add capabilities if they don't already exist
    if ( ! $shop_manager->has_cap('edit_users') ) {
        // Core WP + WooCommerce capabilities
        $shop_manager->add_cap('list_users');
        $shop_manager->add_cap('edit_users');
        $shop_manager->add_cap('create_users');
        $shop_manager->add_cap('promote_users');
        $shop_manager->add_cap('add_users');
    }
}
add_action('init', 'wws_add_shop_manager_user_editing_capability');

/**
 * Allow Shop Managers to edit wholesale roles.
 */
function wws_allow_shop_manager_wholesale_roles( $roles ) {
    $wholesale_roles = array(
        'wholesale_customer',
        'wholesale_gold',
    );

    foreach ( $wholesale_roles as $role ) {
        // Only add if the role exists in WordPress
        if ( get_role( $role ) && ! in_array( $role, $roles, true ) ) {
            $roles[] = $role;
        }
    }

    return $roles;
}
add_filter('woocommerce_shop_manager_editable_roles', 'wws_allow_shop_manager_wholesale_roles', 20);

/**
 * Some versions of Wholesale Prices Premium use their own editable roles filter.
 * Note: This filter may not exist in current versions - keeping for backward compatibility.
 */
function wws_allow_shop_manager_wholesale_roles_wholesale_suite( $roles ) {
    $wholesale_roles = array(
        'wholesale_customer',
        'wholesale_gold',
    );

    foreach ( $wholesale_roles as $role ) {
        // Only add if the role exists in WordPress
        if ( get_role( $role ) && ! in_array( $role, $roles, true ) ) {
            $roles[] = $role;
        }
    }

    return $roles;
}
add_filter('wwp_shop_manager_editable_roles', 'wws_allow_shop_manager_wholesale_roles_wholesale_suite', 20);


What This Snippet Does

  • Restores user editing capabilities for the Shop Manager role, allowing them to view, edit, and promote users.
  • Adds support for wholesale roles, such as wholesale_customer or other wholesalle custom roles.
  • Maintains backward compatibility with older versions of the Wholesale Prices Premium plugin that use a different filter.

You can add or remove wholesale roles from the $wholesale_roles array as needed to match your site’s configuration.

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support
Complete Your Purchase