elseif ($contactId === 0) {
//anonymous user
$contact = [];
- CRM_Utils_Hook::tokenValues($contact, $contactId, $job_id);
+ CRM_Utils_Hook::tokenValues($contact, [$contactId], $job_id);
}
else {
$params = [['contact_id', '=', $contactId, 0, 0]];
list($contact) = CRM_Contact_BAO_Query::apiQuery($params);
+ // $contact is an array of [ contactID => contactDetails ]
- //CRM-4524
- $contact = reset($contact);
+ // also call the hook to get contact details
+ CRM_Utils_Hook::tokenValues($contact, [$contactId], $job_id);
+ // Don't send if contact doesn't exist
+ $contact = reset($contact);
if (!$contact || is_a($contact, 'CRM_Core_Error')) {
CRM_Core_Error::debug_log_message(ts('CiviMail will not send email to a non-existent contact: %1',
[1 => $contactId]
$res = NULL;
return $res;
}
-
- // also call the hook to get contact details
- CRM_Utils_Hook::tokenValues($contact, $contactId, $job_id);
}
$pTemplates = $this->getPreparedTemplates();