public static function getUserRoles($incl_admin = true)
    {
        $wp_roles = new \WP_Roles();
        $wp_roles = $wp_roles->get_names();
        if (!$incl_admin) {
            unset($wp_roles['administrator']);
        }
        $roles = [];
        foreach ($wp_roles as $key => $value) {
            $roles[] = $key;
        }
        return $roles;
    }
public static function getUserRoles($incl_admin = true)
    {
        $wp_roles = new \WP_Roles();
        $wp_roles = $wp_roles->get_names();
        if (!$incl_admin) {
            unset($wp_roles['administrator']);
        }
        $roles = [];
        foreach ($wp_roles as $key => $value) {
            $roles[] = $key;
        }
        return $roles;
    }
public static function getUserRoles ( $ incl_admin = true ) { $ wp_roles = new \ WP_Roles ( ) ; $ wp_roles = $ wp_roles -> get_names ( ) ; if ( ! $ incl_admin ) { unset ( $ wp_roles [ 'administrator' ] ) ; } $ roles = [ ] ; foreach ( $ wp_roles as $ key => $ value ) { $ roles [ ] = $ key ; } return $ roles ; }
Get all user roles from WordPress

@param bool $include_admin
@return array
Get all user roles from WordPress