Skip to content

Commit

Permalink
CIWEM-407: Fix confirmation email for event registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Shahrukh committed Jun 20, 2024
1 parent 3a75176 commit 8e18bcf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
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);
}
}
}

0 comments on commit 8e18bcf

Please sign in to comment.