I am trying to add contact created date in contact summary. I am sure that https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_summary/ helps the requirement. But I'm not getting how to implement this hook.Any help please?
As already pointed out, the created date is shown on the summary anyway - but since your question is more about using hook_civicrm_summary()
, here's an simple example to add the date above the existing summary content:
function demo_civicrm_summary($contactID, &$content, &$contentPlacement) {
// Lookup 'created_date' for the specified contact
$dateCreated = civicrm_api3('Contact', 'getValue', array(
'id' => $contactID,
'return' => 'created_date',
));
// Set $content to what we want to display
// Can add html with classes for formatting ...
$content = 'Date created: ' . $dateCreated;
// Set $contentPlacement to specify where our content is displayed.
// The default if we don't set this is to display below the existing summary
$contentPlacement = CRM_Utils_Hook::SUMMARY_ABOVE;
}
The contact created date does show up on Contact Summary page at the bottom of the summary page
If you want as a field to show in summary section then i feel you can use civicrm_summary hook but it would to be very difficult to manipulate where to insert a section in $content as it would be pure html. I would use Buildform and/or Page run hook to add field with some JS to place the field in the page/form.
HTH
Pradeep
-
I expect you know the data is in civicrm_contact.created_date field but since no one has mentioned that i thought i should state the obvious – petednz - fuzion♦ Jun 7 '18 at 21:20