Support » Plugin: Ultimate Member - User Profile & Membership Plugin » WordPress/Ultimate Member- Search feature by metadata

  • The users of our new intranet that we have developed using wordpress and ultimate member have asked if we are able to provide additional functionality for them.

    Currently, we have an “our people” page where users can search for people throughout our company using their first name and surname, which works using code that was provided ultimate member to allow this.

    HR would now like us to be able to search by a users number plate which will then tell HR who that car belongs to – for example, in a case that something has happened to the car or it is blocking an entrance etc.

    Here is the code that we are trying / the code that ultimate member gave us:

    add_filter( 'um_member_directory_general_search_meta_query', 'cust_search_usrs', 10, 2 );
    function cust_search_usrs( $meta_query, $search ){
        $meta_query = array();
        return $meta_query;
    add_filter( 'um_prepare_user_query_args', 'um_user_before_query_usrs', 10, 2 );
    function um_user_before_query_usrs( $query_args, $directory_data ){
    global $current_user;
    global $current_user_Location;
    $current_user = wp_get_current_user();
    if( isset( $_POST['search'] ) && $_POST['search'] != '' ) {
               $query_args['search_columns'] = array( 'first_name', 'last_name', 'display_name', 
    'Job_Title', 'Department_Team', 'Extension', 'Mobex', 'mobile_number', 'numberplate1' );
               $query_args['search']         = '*' . $_POST['search'] . '*';
        return $query_args;

    The numberplate1 is metadata which is part of our table that we have for each user.

    What we would like to achieve is that the search feature will allow the user to search a numberplate and it will return a result based on that numberplate.

    Could anyone please help us with this?


    • This topic was modified 1 month, 2 weeks ago by aralmac123.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.