Skip to content

Instantly share code, notes, and snippets.

@dawehner
Forked from anonymous/gist:6611959
Last active December 23, 2015 09:09
Show Gist options
  • Save dawehner/6612021 to your computer and use it in GitHub Desktop.
Save dawehner/6612021 to your computer and use it in GitHub Desktop.
/**
* Implements hook_views_data_alter().
*/
function feature_user_views_data_alter(&$data) {
// Actions
$data['users']['profession'] = array(
'title' => t('Profession'),
'help' => t('Profession of a user'),
'field' => array(
'handler' => 'views_handler_field_user_profession',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
// This will show a term relationship on a user view
'relationship' => array(
'handler' => 'views_handler_relationship',
'base' => 'taxonomy_term_data',
'base field' => 'tid',
),
);
// If you need to join automatically use that
$data['taxonomy_term_data']['table']['join']['users'] = array(
'field' => 'tid',
'left_field' => 'profession',
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment