Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIWEM-407: Fix Confirmation Email For Event Registration #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* Alter mail params hook for event registration confirmation.
*/
class CRM_EventsExtras_Hook_AlterMailParams_EventRegistrationConfirmation {

public static function shouldHandle(array $params, $context): bool {
return !empty($params['tplParams']['event']) && !empty($params['tplParams']['custom_pre_id']) && !empty($params['tplParams']['contactID'])
&& $context === 'messageTemplate' && isset($params['tplParams']['customPre'][0]) && count(array_filter($params['tplParams']['customPre'][0])) === 0;
}

public function handle(array &$params): void {
$fields = CRM_Core_BAO_UFGroup::getFields($params['tplParams']['custom_pre_id'], FALSE, CRM_Core_Action::VIEW,
NULL, NULL, FALSE, NULL,
FALSE, NULL, CRM_Core_Permission::CREATE,
'field_name', TRUE
);

$values = [];
CRM_Core_BAO_UFGroup::getValues($params['tplParams']['contactID'], $fields, $values, FALSE);

$params['tplParams']['customPre'][0] = $values;
}

}
13 changes: 13 additions & 0 deletions eventsextras.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,16 @@ function eventsextras_civicrm_navigationMenu(&$menu) {
));
_eventsextras_civix_navigationMenu($menu);
}

/**
* Implements hook_civicrm_alterMailParams().
*/
function eventsextras_civicrm_alterMailParams(&$params, $context) {
$hooks = [CRM_EventsExtras_Hook_AlterMailParams_EventRegistrationConfirmation::class];

foreach ($hooks as $hook) {
if ($hook::shouldHandle($params, $context)) {
(new $hook())->handle($params, $context);
}
}
}
Loading