Change WordPress user roles and capabilities Forums Bug Reports Update 4.48 – User role only customer on Multisites Reply To: Update 4.48 – User role only customer on Multisites

#5190
Vladimir
Keymaster

No need in access to your site copy. I just re-tested WC v. 3.4.6 and reproduced the issue.
Good news: All roles are in place and just not shown while WooCommerce is active. I investigated the issue and found a serious bug in WooCommerce code:

Look at the line #339. current_user_can() always returns true for WP multisite superadmin user. Thus this code hides all roles except ‘customer’. This function is located inside ‘includes/wc-user-functions.php’ file.
It’s a new behaviour. This code was added from version 3.4.6

You have 2 variants until they fix this:

1) rollback to prev. version of WC 3.4.5

or

2) comment lines 339-342 in the updated function. It looked this way at version 3.4.5:


function wc_modify_editable_roles( $roles ) {
    if ( ! current_user_can( 'administrator' ) ) {
        unset( $roles['administrator'] );
    }
    return $roles;
}