Contextual filter that lists users who share a taxonomy term with current user? I have a view that lists all user profiles. At registration, every user selects, from a 'sector' taxonomy, the sector they themselves do business in. They also select from the same 'sector' taxonomy to record what sectors they want to do business with. So their user profiles may look like this:

uid: 1
name: fred
sector in: arts
sectors to do business with: tech

uid: 2
name: alex
sector in: tech
sectors to do business with: design


I want a view to list all the users that do business in the sectors that the current user wants to do business in.

So, using the above profiles, if Fred was looking at the view, Alex's profile would be displayed because the filter would be:

sector == tech


Obviously, the filter needs to be dynamic. It needs to grab the 'sectors to do business with' field from Fred's user profile. I think I need a contextual filter, but how do I configure it?

Thanks
Provided you have two fields on your user profile called field_working_in and field_want_to_work_with execute the following steps:


Add a Users view at admin/structure/views/add and set Display Format as Table
Add two fields User: Name and User: Working in
Add relationship with  User: Working in
Add relationship with Taxonomy term: User using Want to work with
Add a contextual filter: User: uid with Provide Default Value and Type: User ID form logged in User and set a relationship with field_want_to_work_with (see screenshot)
Under FILTER CRITERIA Add the following filter to exclude the current user from the results: User: Current (No)


Export of view:

$view = new view();
$view-&gt;name = 'user_sections';
$view-&gt;description = '';
$view-&gt;tag = 'default';
$view-&gt;base_table = 'users';
$view-&gt;human_name = 'User sections';
$view-&gt;core = 7;
$view-&gt;api_version = '3.0';
$view-&gt;disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view-&gt;new_display('default', 'Master', 'default');
$handler-&gt;display-&gt;display_options['title'] = 'User sections';
$handler-&gt;display-&gt;display_options['use_more_always'] = FALSE;
$handler-&gt;display-&gt;display_options['access']['type'] = 'perm';
$handler-&gt;display-&gt;display_options['access']['perm'] = 'access user profiles';
$handler-&gt;display-&gt;display_options['cache']['type'] = 'none';
$handler-&gt;display-&gt;display_options['query']['type'] = 'views_query';
$handler-&gt;display-&gt;display_options['exposed_form']['type'] = 'basic';
$handler-&gt;display-&gt;display_options['pager']['type'] = 'full';
$handler-&gt;display-&gt;display_options['pager']['options']['items_per_page'] = '10';
$handler-&gt;display-&gt;display_options['style_plugin'] = 'table';
/* Relationship: User: Working in (field_working_in) */
$handler-&gt;display-&gt;display_options['relationships']['field_working_in_tid']['id'] = 'field_working_in_tid';
$handler-&gt;display-&gt;display_options['relationships']['field_working_in_tid']['table'] = 'field_data_field_working_in';
$handler-&gt;display-&gt;display_options['relationships']['field_working_in_tid']['field'] = 'field_working_in_tid';
/* Relationship: Taxonomy term: User using Want to work with */
$handler-&gt;display-&gt;display_options['relationships']['reverse_field_want_to_work_with_user']['id'] = 'reverse_field_want_to_work_with_user';
$handler-&gt;display-&gt;display_options['relationships']['reverse_field_want_to_work_with_user']['table'] = 'taxonomy_term_data';
$handler-&gt;display-&gt;display_options['relationships']['reverse_field_want_to_work_with_user']['field'] = 'reverse_field_want_to_work_with_user';
$handler-&gt;display-&gt;display_options['relationships']['reverse_field_want_to_work_with_user']['relationship'] = 'field_working_in_tid';
/* Field: User: Name */
$handler-&gt;display-&gt;display_options['fields']['name']['id'] = 'name';
$handler-&gt;display-&gt;display_options['fields']['name']['table'] = 'users';
$handler-&gt;display-&gt;display_options['fields']['name']['field'] = 'name';
$handler-&gt;display-&gt;display_options['fields']['name']['alter']['word_boundary'] = FALSE;
$handler-&gt;display-&gt;display_options['fields']['name']['alter']['ellipsis'] = FALSE;
/* Field: User: Working in */
$handler-&gt;display-&gt;display_options['fields']['field_working_in']['id'] = 'field_working_in';
$handler-&gt;display-&gt;display_options['fields']['field_working_in']['table'] = 'field_data_field_working_in';
$handler-&gt;display-&gt;display_options['fields']['field_working_in']['field'] = 'field_working_in';
$handler-&gt;display-&gt;display_options['fields']['field_working_in']['label'] = '';
$handler-&gt;display-&gt;display_options['fields']['field_working_in']['element_type'] = '0';
$handler-&gt;display-&gt;display_options['fields']['field_working_in']['element_label_colon'] = FALSE;
$handler-&gt;display-&gt;display_options['fields']['field_working_in']['element_wrapper_type'] = '0';
$handler-&gt;display-&gt;display_options['fields']['field_working_in']['element_default_classes'] = FALSE;
$handler-&gt;display-&gt;display_options['fields']['field_working_in']['delta_offset'] = '0';
$handler-&gt;display-&gt;display_options['fields']['field_working_in']['field_api_classes'] = TRUE;
/* Sort criterion: User: Created date */
$handler-&gt;display-&gt;display_options['sorts']['created']['id'] = 'created';
$handler-&gt;display-&gt;display_options['sorts']['created']['table'] = 'users';
$handler-&gt;display-&gt;display_options['sorts']['created']['field'] = 'created';
$handler-&gt;display-&gt;display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: User: Uid */
$handler-&gt;display-&gt;display_options['arguments']['uid']['id'] = 'uid';
$handler-&gt;display-&gt;display_options['arguments']['uid']['table'] = 'users';
$handler-&gt;display-&gt;display_options['arguments']['uid']['field'] = 'uid';
$handler-&gt;display-&gt;display_options['arguments']['uid']['relationship'] = 'reverse_field_want_to_work_with_user';
$handler-&gt;display-&gt;display_options['arguments']['uid']['default_action'] = 'default';
$handler-&gt;display-&gt;display_options['arguments']['uid']['default_argument_type'] = 'current_user';
$handler-&gt;display-&gt;display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler-&gt;display-&gt;display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler-&gt;display-&gt;display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';
/* Filter criterion: User: Active */
$handler-&gt;display-&gt;display_options['filters']['status']['id'] = 'status';
$handler-&gt;display-&gt;display_options['filters']['status']['table'] = 'users';
$handler-&gt;display-&gt;display_options['filters']['status']['field'] = 'status';
$handler-&gt;display-&gt;display_options['filters']['status']['value'] = '1';
$handler-&gt;display-&gt;display_options['filters']['status']['group'] = 1;
$handler-&gt;display-&gt;display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: User: Current */
$handler-&gt;display-&gt;display_options['filters']['uid_current']['id'] = 'uid_current';
$handler-&gt;display-&gt;display_options['filters']['uid_current']['table'] = 'users';
$handler-&gt;display-&gt;display_options['filters']['uid_current']['field'] = 'uid_current';
$handler-&gt;display-&gt;display_options['filters']['uid_current']['value'] = '0';

/* Display: Page */
$handler = $view-&gt;new_display('page', 'Page', 'page');
$handler-&gt;display-&gt;display_options['path'] = 'user-sections';
$handler-&gt;display-&gt;display_options['menu']['type'] = 'normal';
$handler-&gt;display-&gt;display_options['menu']['title'] = 'User sections';
$handler-&gt;display-&gt;display_options['menu']['weight'] = '0';
$handler-&gt;display-&gt;display_options['menu']['name'] = 'main-menu';
$handler-&gt;display-&gt;display_options['menu']['context'] = 0;
$handler-&gt;display-&gt;display_options['menu']['context_only_inline'] = 0;
$translatables['user_sections'] = array(
  t('Master'),
  t('User sections'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('Items per page'),
  t('- All -'),
  t('Offset'),
  t('« first'),
  t('‹ previous'),
  t('next ›'),
  t('last »'),
  t('term from field_working_in'),
  t('field_want_to_work_with'),
  t('Name'),
  t('All'),
  t('Page'),
);