The right way to solve this is by writing a default argument handler. A patch to do this was started here: https://www.drupal.org/node/721390
A "shortcut" to doing this would be to use the PHP Code default argument handler and plug it in directly. This is not generally recommended; it would be much better to put the code in a custom default argument handler so you should Google around for how to set one of those up as that's a bit beyond the scope of this question. But here are the steps for using the PHP Code approach and you can use the same logic for a default argument handler:
- Create a view listing users
- Add a contextual filter to filter on the user skills field
- In the contextual filter option, for "When the filter is not in the
URL" choose "Provide a default value" and select "PHP Code" from the
list.
- Assuming your field is named "field_skills", enter the following:
PHP code:
global $user;
$account = user_load($user->uid);
$terms = array();
if (!empty($account->field_skills['und'])) {
foreach ($account->field_skills['und'] as $value) {
$terms[] = $value['tid'];
}
}
return implode('+', $terms);
- Down towards the bottom of that form there's a "more" link. Be sure
to open that section of the form and select "Allow multiple values".
At this point, you should have the list that you want with one caveat: the currently logged-in user will show up in this list. You probably don't want this. To prevent that from happening add another contextual filter that excludes the current user from the list:
- Add a contextual filter on the User:Uid value
- Choose "Provide default value" for "When the filter is not in the
URL" and, out of that list, choose "User ID from logged in user".
- Under the "more" link at the bottom, choose the "Exclude" option.
skill value