- Issue created by @trichers
- πΊπΈUnited States owenbush Denver, CO
At the moment, there is no mechanism in place to send emails to an administrator when a registration is made.
If you wanted to be able to customize the message sent out in the Drupal admin, you could implement the following hook:
hook_recurring_events_registration_notification_types()
to add a new notification type, for example 'admin_registration_notification'. See the recurring_events_registration.module file for how this is done./** * Implements hook_recurring_events_registration_notification_types_alter(). */ function recurring_events_registration_recurring_events_registration_notification_types_alter(array &$notification_types) { $notification_types += [ 'admin_registration_notification' => [ 'name' => t('Admin Registration Notification'), 'description' => t('Send an email to an admin when someone registers for an event?'), ], ]; }
Then you could probably implement hook_ENTITY_TYPE_insert() with ENTITY_TYPE being 'registrant', with something like this:
use Drupal\Core\Entity\EntityInterface; /** * Implements hook_ENTITY_TYPE_insert(). */ function YOUR_MODULE_registration_insert(EntityInterface $entity) { $key = admin_registration_notification'; $to = 'your-admin-email@domain.com'; $mail = \Drupal::service('plugin.manager.mail'); $params = [ 'registrant' => $entity, ]; $mail->mail('recurring_events_registration', $key, $to, \Drupal::languageManager()->getDefaultLanguage()->getId(), $params); }
- π©πͺGermany trichers
Thanks for this fast and great feedback!
I had to correct one thing
function YOUR_MODULE_registration_insert(EntityInterface $entity) {
It does not have to be registration_insert, but registrant_insert, then it works.
use Drupal\Core\Entity\EntityInterface; /** * Implements hook_ENTITY_TYPE_insert(). */ function YOUR_MODULE_registrant_insert(EntityInterface $entity) { $key = 'admin_registration_notification'; $to = 'your-admin-email@domain.com'; $params = [ 'registrant' => $entity, ]; $mail = \Drupal::service('plugin.manager.mail'); $mail->mail('recurring_events_registration', $key, $to, \Drupal::languageManager()->getDefaultLanguage()->getId(), $params); }
- πΊπΈUnited States owenbush Denver, CO
Ah yes, sorry. Great catch. I am glad it works for you!
- Status changed to Fixed
11 months ago 4:00pm 17 December 2023 - Status changed to Fixed
11 months ago 4:01pm 17 December 2023