Skip to content

invoke hooks to determine message template to use for attendance certificates

Invoke a new hook to be able to set which message template id is used when generating Attendance certificates in custom extension

Example:

/**
 * Implements hook_civicrm_certificate_message_template_id().
 */
function commonfix_civicrm_certificate_message_template_id(&$messageTemplateID, $participant_id) {
  if (!empty($participant_id)) {
    $participant = Participant::get(FALSE)
      ->addSelect('*', 'status_id:name', 'contact_id.display_name', 'event_id.id', 'event_id.title',  'event_id.event_type_id', 'event_id.Event_Certificate.download_certificate', 'event_id.Event_Certificate.Certificate_Template')
      ->addWhere('id', '=', $participant_id)
      ->execute()
      ->first();
    // TODO, conditionally choose template.
    if (!empty($participant['event_id.Event_Certificate.Certificate_Template'])) {
      $messageTemplateID = $participant['event_id.Event_Certificate.Certificate_Template'];
    }
    else {
      $messageTemplateID = 0;
    }
  }
}
Edited by jackrabbithanna

Merge request reports

Loading