• Resolved mariontubiana

    (@mariontubiana)


    Hello everyone,

    It’s me again I’m sorry …

    When I use the search function in the member directory, this search applies to all of my members’ profiles.
    I would like the search to apply only to first and last names.

    Let me explain, for example if I search for Nathalie, the only member that appears is “Armelle Panay” because she quotes the word Nathalie once in her profile.

    Thank you

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @mariontubiana

    You can try using the following Code Snippets to restrict the search filter to just use the First Name and Last Name.

    add_filter('um_member_directory_general_search_meta_query','um_011022_member_search_specific', 10, 2);
    function um_011022_member_search_specific( $meta_query, $search_keyword ){
    
        $meta_query = array(
            'relation' => 'OR',
            array(
                'meta_key'  => 'first_name',
                'value'     => $search_keyword,
                'compare'   => 'LIKE',
            ),
            array(
                'meta_key'  => 'last_name',
                'value'     => $search_keyword,
                'compare'   => 'LIKE',
            ),
            
        );
    
        return $meta_query;
    }

    You can add the code to your theme/child-theme’s functions.php file or use the Code Snippets plugin to run the code.

    Regards,

    Thread Starter mariontubiana

    (@mariontubiana)

    Hi @champsupertramp

    Thank you, I add the code but doesn’t work :/

    https://zupimages.net/up/22/02/llxp.png

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @mariontubiana

    Are you using a custom user meta table? You can confirm it in WP Admin > Ultimate Member > Settings > Misc > “Enable custom table for usermeta”. Is it checked?

    Regards,

    Thread Starter mariontubiana

    (@mariontubiana)

    @champsupertramp No, the “Enable custom table for usermeta” isn’t checked

    Besides, I take this screenshot to emphasize the fact that the button appears really odd with my theme (it works with the other themes tested).
    I don’t know why it appears cut off and not clickable

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @mariontubiana

    Please try adding this code. This should search the first name and last name fields only:

    add_filter("um_general_search_custom_fields","um_011122_member_search_specific_field");
    function um_011122_member_search_specific_field( $custom_fields ){
    
        return array('first_name','last_name');
    }

    As for the button, do you have a link to your member directory page so I can see the issue and then see if I can create CSS code to fix the issue?

    Regards,

    Thread Starter mariontubiana

    (@mariontubiana)

    Hi @champsupertramp

    The code works fine for the search function, thank you very much!
    You rock in the UM team I’m super happy!

    For the button, I also asked the question to the developer of the theme because it seems that the button works with the others but not with my current theme …
    Here is the link for my member directory page :
    https://mondialartacademia.com/members/

    Regards,
    Marion

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @mariontubiana

    I just checked the button and it looks like an issue with the theme. Let me know when the theme developer responds.

    Regards,

    Thread Starter mariontubiana

    (@mariontubiana)

    Hi,

    Here is the mail of Bard team :
    https://zupimages.net/up/22/02/6r7n.jpeg

    I reply that I use UM.
    Waiting for a respons

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @mariontubiana

    Try adding this CSS:

    input.um-do-search.um-button {
        background: #896565;
        cursor: pointer;
    }

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hey there!

    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 by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Search function name and last name only’ is closed to new replies.