Skip to content

Instantly share code, notes, and snippets.

@mecachisenros
Created April 5, 2016 15:43
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 mecachisenros/785d9d8eef15359b4f66a332406b7b0e to your computer and use it in GitHub Desktop.
Save mecachisenros/785d9d8eef15359b4f66a332406b7b0e to your computer and use it in GitHub Desktop.
function myextension_civicrm_contact_get_displayname(&$display_name, $contactId, $objContact) {
$membership_id = civicrm_api3('Membership', 'get', array(
'sequential' => 1,
'contact_id' => $contactId,
'return' => 'id',
));
if($membership_id['is_error'] == true || $membership_id['count'] !== 0){
$display_name = $display_name . ' - Member ID: '.$membership_id['values'][0]['id'];
} else {
$display_name = $display_name;
}
}
@mecachisenros
Copy link
Author

Implements hook_civicrm_contact_get_displayname to display the Member Id if the contact has a Membership
member_id

@saxotenor
Copy link

Hi Andrei,
This seems to exactly the thing I need for my CiviCRM (under WordPress) but I'm absolute newbie on hooks. Where do I put the code you have there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment