2 Clean up
source | link
function wpse_set_pre_get_users( $query ){
    if( ! is_admin() ){

        $meta_query = $query->get( 'meta_query' );
        $meta_new_query = array();

        if( get_query_var( 'search' ) != '' ){
            $search_arr = explode( '/', get_query_var( 'search' ) );

// Organise the search variables
        foreach ( $search_arr as $search_val ) {
                $vals = explode( '=', $search_val );

                $serialize_value = serialize( strval( urldecode( $vals[ 0 ] ) ) );
                $meta_new_query = array(
                    array(
                        'key' => $vals[ 1 ],
                        'value' => trim( urldecode( $vals[ 0 ] ) ),
                        'compare' => '=',
                    ), 
                    array(
                        'key' => $vals[ 1 ],
                        'value' => trim( urldecode( $vals[ 0 ] ) ),
                        'compare' => 'LIKE',
                    ), 
                    array(
                        'key' => $vals[ 1 ],
                        'value' => trim( $serialize_value ),
                        'compare' => 'LIKE',
                    ), 
                    'relation' => 'OR',
                );
                $meta_query = array_merge( $meta_query, array( $meta_new_query ) );
            }

            $query->set( 'meta_query', $meta_query );
        }
    }
}

add_action( 'pre_get_users','wpse_set_pre_get_users' );
function wpse_set_pre_get_users( $query ){
    if( ! is_admin() ){

        $meta_query = $query->get( 'meta_query' );
        $meta_new_query = array();

        $search_arr = explode( '/', get_query_var( 'search' ) );

// Organise the search variables
        foreach ( $search_arr as $search_val ) {
            $vals = explode( '=', $search_val );

            $serialize_value = serialize( strval( urldecode( $vals[ 0 ] ) ) );
            $meta_new_query = array(
                array(
                    'key' => $vals[ 1 ],
                    'value' => trim( urldecode( $vals[ 0 ] ) ),
                    'compare' => '=',
                ), 
                array(
                    'key' => $vals[ 1 ],
                    'value' => trim( urldecode( $vals[ 0 ] ) ),
                    'compare' => 'LIKE',
                ), 
                array(
                    'key' => $vals[ 1 ],
                    'value' => trim( $serialize_value ),
                    'compare' => 'LIKE',
                ), 
                'relation' => 'OR',
            );
            $meta_query = array_merge( $meta_query, array( $meta_new_query ) );
        }

        $query->set( 'meta_query', $meta_query );
    }
}

add_action( 'pre_get_users','wpse_set_pre_get_users' );
function wpse_set_pre_get_users( $query ){
    if( ! is_admin() ){

        $meta_query = $query->get( 'meta_query' );
        $meta_new_query = array();

        if( get_query_var( 'search' ) != '' ){
            $search_arr = explode( '/', get_query_var( 'search' ) );

            foreach ( $search_arr as $search_val ) {
                $vals = explode( '=', $search_val );

                $serialize_value = serialize( strval( urldecode( $vals[ 0 ] ) ) );
                $meta_new_query = array(
                    array(
                        'key' => $vals[ 1 ],
                        'value' => trim( urldecode( $vals[ 0 ] ) ),
                        'compare' => '=',
                    ), 
                    array(
                        'key' => $vals[ 1 ],
                        'value' => trim( urldecode( $vals[ 0 ] ) ),
                        'compare' => 'LIKE',
                    ), 
                    array(
                        'key' => $vals[ 1 ],
                        'value' => trim( $serialize_value ),
                        'compare' => 'LIKE',
                    ), 
                    'relation' => 'OR',
                );
                $meta_query = array_merge( $meta_query, array( $meta_new_query ) );
            }

            $query->set( 'meta_query', $meta_query );
        }
    }
}

add_action( 'pre_get_users','wpse_set_pre_get_users' );
1
source | link

For those interested I got around it by doing the following

add_rewrite_rule( 'members/search/(.+?)?$',
    'index.php?page_id=' . $member_page_id . '&search=$matches[1]',
    'top'
);

So essentially getting everything after the search then dealing that when parsing the query I then parsed the query like so from the 'search' query_var

function wpse_set_pre_get_users( $query ){
    if( ! is_admin() ){

        $meta_query = $query->get( 'meta_query' );
        $meta_new_query = array();

        $search_arr = explode( '/', get_query_var( 'search' ) );

// Organise the search variables
        foreach ( $search_arr as $search_val ) {
            $vals = explode( '=', $search_val );

            $serialize_value = serialize( strval( urldecode( $vals[ 0 ] ) ) );
            $meta_new_query = array(
                array(
                    'key' => $vals[ 1 ],
                    'value' => trim( urldecode( $vals[ 0 ] ) ),
                    'compare' => '=',
                ), 
                array(
                    'key' => $vals[ 1 ],
                    'value' => trim( urldecode( $vals[ 0 ] ) ),
                    'compare' => 'LIKE',
                ), 
                array(
                    'key' => $vals[ 1 ],
                    'value' => trim( $serialize_value ),
                    'compare' => 'LIKE',
                ), 
                'relation' => 'OR',
            );
            $meta_query = array_merge( $meta_query, array( $meta_new_query ) );
        }

        $query->set( 'meta_query', $meta_query );
    }
}

add_action( 'pre_get_users','wpse_set_pre_get_users' );