• Resolved 01RAD

    (@01radteam)


    Hi All, please check the solution below:

    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' );
  • The topic ‘Can’t Assign Roles on WordPress Multisite (Except Customer) – Solved’ is closed to new replies.