How to ignore search string case when using WP_User_Query?

Using the following code, how can I do the search by ignoring the case of the field in the database :

    $args = array(
    'meta_query' => array(
        'relation' => 'OR',
        array(
            array(
            'key'     => 'province',
            'value'   => 'kzn',
            'compare' => '='
            ),
        )
    )
 );
$user_query = new WP_User_Query( $args );

In the above example, ‘kzn’ is stored as KZN in the database. The input search string can be ‘Kzn’, or ‘kZn… etc. The value to search for can also be a mixed bag as far as it’s case goes. So I guess what I am looking for is a war to search for uppercase(databasefield) in the value field, if that makes sense.

Read More

Thank you.

Related posts

1 comment

  1. Got it.

    (
        'key'     => 'province',
        'value'   => ('^'.$province),
        'compare' => 'REGEXP'
    );
    

Comments are closed.