How to customize user search

I was able to find a solution:

if(!empty($search)){
   $query = $wpdb->prepare( 
                 "SELECT DISTINCT user_id
                  FROM wp_usermeta
                  WHERE meta_key = 'pie_address_3'
                  AND meta_value LIKE %s
                  ", '%' . $search . '%' );

                $ids = $wpdb->get_results($query); ?> 
                <ul class="author-list"> 
                    <?php
                    foreach ($ids as $id) { ?>
                        <li>
                            <img width="90" height="90" src="https://wordpress.stackexchange.com/questions/182955/<?php echo get_user_meta($id->user_id,"pie_profile_pic_5", true); ?>" 
                                                                 class="attachment-agent-image wp-post-image">
                            <h2 style="display: inline; margin-left: 20px;">
                                <a href="<?php echo get_author_posts_url($id->user_id); ?>"><?php echo get_the_author_meta('first_name', $id->user_id); ?> 
                                    <?php echo get_the_author_meta('last_name', $id->user_id); ?>
                                </a>
                                - <?php echo count_user_posts($id->user_id); ?> immobili
                            </h2>
                        </li>
                    <?php } ?>
                </ul>
 <?php } ?>