You are using a plugin for search?
The two part you mentioned are bit different:
The search will simply return a list of user that share tags.
You have id of tag for which you want user list, you can easily get that using get_objects_in_term()
, its a WordPress function that will return you list of all users having that tag.
The list will show users that share most tags on top, fewer tags shared lower down.
That seems to be bit complex,
You can get the list of user,
$share = array();
foreach(users as user) {
$share_count = 0;
$tags_for_user = get tag for current user;
if( !empty($tags_for_user) ) {
foreach ($tags_for_user as $tag ) {
$users_for_tag = get_objects_in_term();
$share_count += (int)count($users_for_tag);
}
}
$share[$user_id] = $share_count;
}
$share = sort $share;
That way you’ll get total number of users which has maximum same interest.
Hope that helps.