As you haven’t offered the details on what you’re after, I’ll try to grab them all very briefly.
Use the API – public WP_User_Query
API functions
Basically get_user_by()
should be enough for you. Let’s say you fire of your form and the input field name
was user_id
. So you’d just retrieve the value from the $_REQUEST
(or $_GET
) and then do a simple query.
$user = get_user_by( 'user_id', $_REQUEST['user_id'] );
Advanced Task: Meta User Query
If you’re going to do more complex requests (for maybe only a partly request that covers more than one user as possible result), then it’s time to call get_users()
, which is the default API wrapper for new WP_User_Query
.
A meta query could look like this:
$args = array(
'meta_key' => 'custom-usermeta',
'meta_value' => $cat_id,
'meta_compare' => '='
);
$users = get_users( $args );
AJAX Search
If you need AJAX search functionality, just take a look at the answers filed under ajax to get around it – no reason repeating it here.
I have asked a question about autocomplete some time ago and covers the most important parts.
// jQuery autocomplete - already bundled with WP core
function wpse71343_scripts()
{
wp_enqueue_script( 'jquery-ui-autocomplete' );
}
add_action( 'wp_enqueue_scripts', 'wpse71343_scripts' );