Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackrabbithanna/94d2f6cf222a01a657200d01b96882c8 to your computer and use it in GitHub Desktop.
Save jackrabbithanna/94d2f6cf222a01a657200d01b96882c8 to your computer and use it in GitHub Desktop.
Contact -> User, User -> Contact hook_views_data_alter()
$data['civicrm_contact']['user'] = [
'title' => 'User related to the CiviCRM contact',
'help' => 'Relate user to the CiviCRM contact.',
'relationship' => [
'base' => 'users_field_data',
'base field' => 'uid',
'first field' => 'contact_id',
'second field' => 'uf_id',
'id' => 'civicrm_entity_civicrm_contact_user',
'label' => 'User',
],
];
$data['users_field_data']['civicrm_contact'] = [
'title' => 'CiviCRM contact related to the user',
'help' => 'Relate CiviCRM contact to the user.',
'relationship' => [
'base' => 'civicrm_contact',
'base field' => 'id',
'first field' => 'uf_id',
'second field' => 'contact_id',
'id' => 'civicrm_entity_civicrm_contact_user',
'label' => 'CiviCRM contact',
],
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment