• Resolved KeanuTang

    (@tedtang)


    I have advanced filters set up for my user directory. Is it possible to make one of the fields only search as an exact match?

    A little more context… These are alumni with class numbers (not years) assigned. If they type a “2”, we want to only return exact matches where the alumni have exactly “2” as the class number. Right now it’s returning any class number that contains a “2” like “12”, “22”, “23”, etc.

    Thanks for your help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter KeanuTang

    (@tedtang)

    I ended up doing this:

    /* When filtering on class number, perform an exact match */
    add_action("um_user_before_query","um_exact_class_number_match", 10, 2 );
    function um_exact_class_number_match( $query_args, $obj ){
    ? ? foreach ($obj->query_args['meta_query'] as $key1 => $value1) {
    ? ? ? ? foreach ($obj->query_args['meta_query'][$key1] as $key2 => $value2) {
    ? ? ? ? ? ? if ($obj->query_args['meta_query'][$key1][$key2]['key'] == 'x_ClassNumber') {
    ? ? ? ? ? ? ? ? $obj->query_args['meta_query'][$key1][$key2]['compare'] = '=';
    ? ? ? ? ? ? }
    ? ? ? ? }
    ? ? }
    }
    • This reply was modified 1 year, 6 months ago by KeanuTang.
    Plugin Support andrewshu

    (@andrewshu)

    Hello @tedtang

    Sorry, but customizations are not included in our support.

    Regards.

    Plugin Support andrewshu

    (@andrewshu)

    Hi @tedtang

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread if any other questions come up and we’d be happy to help. ??

    Regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Exact match for a certain filter’ is closed to new replies.