Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hi all, Please check the solution below @correyjames @spencerfcloud @bcworkz

    File Path : \wp-content\plugins\woocommerce\includes\wc-user-functions.php
    Function Name: wc_modify_editable_roles

    ============================================================

    Code Before Changes:

    function wc_modify_editable_roles( $roles ) {
    	if ( ! current_user_can( 'administrator' ) ) {
    		unset( $roles['administrator'] );
    	}
    
    	if ( current_user_can( 'shop_manager' ) ) {
    		$shop_manager_editable_roles = apply_filters( 'woocommerce_shop_manager_editable_roles', array( 'customer' ) );
    		return array_intersect_key( $roles, array_flip( $shop_manager_editable_roles ) );
    	}
    
    	return $roles;
    }
    add_filter( 'editable_roles', 'wc_modify_editable_roles' );

    ===============================================================

    Code After Changes:

    function wc_modify_editable_roles( $roles ) {
    	if ( ! current_user_can( 'administrator' ) ) {
    		unset( $roles['administrator'] );
            
            if ( current_user_can( 'shop_manager' ) ) {
        		$shop_manager_editable_roles = apply_filters( 'woocommerce_shop_manager_editable_roles', array( 'customer' ) );
        		return array_intersect_key( $roles, array_flip( $shop_manager_editable_roles ) );
        	}
    	}
        	
    
    	return $roles;
    }
    add_filter( 'editable_roles', 'wc_modify_editable_roles' );
Viewing 1 replies (of 1 total)