Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@mecachisenros mecachisenros commented Apr 5, 2016

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

@saxotenor

This comment has been minimized.

Copy link

@saxotenor saxotenor commented Jan 7, 2018

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