Tokens containing HTML in notification emails show HTML tags in emails

Created on 15 June 2022, almost 3 years ago
Updated 17 December 2024, 5 months ago

Problem/Motivation

I am using tokens inside emails such as the Registration Reminder email. These tokens come from custom fields I have added to the registration process on the Event Series entity, which can contain full HTML. Specifically, I have a field custom_registration_reminder that I place inside the Registration Reminder email as a token [eventseries:custom_registration_reminder]. This is so event organizers can place a unique registration reminder inside the reminder emails.

My Registration Reminder email set on /admin/structure/events/registrant/settings looks like this:

This is a reminder for your event.

[eventseries:custom_registration_reminder]

I am using Mime Mail module to send emails from my site in HTML format.

When Registration Reminder emails arrive, the HTML from the [eventseries:custom_registration_reminder] token is visible inside the email, not being translated into HTML. For example:

This is a reminder for your event.<p>Custom message should be here.</p>

I would like these emails to parse the HTML from the token.

Steps to reproduce

Add a custom "Text, (formatted, long)" field to the Event Series entity.

Have the content from that field print out in the Registration Reminder email set at /admin/structure/events/registrant/settings

Create an Event Series with content in the new field.

Trigger the Registration Reminder email to be sent and see that the HTML is not formatted properly.

Proposed resolution

I have success getting the formatting correct by changing code inside parseTokenizedString() in NotificationService.php and using Token::replacePlain() instead of Token::replace()

    return $this->token->replace($this->token->replace($string, $data), $data);

to:

    $tokenized_data = $this->token->replacePlain($string, $data);
    return $this->token->replacePlain($tokenized_data, $data);

I am not sure that this has no repercussions elsewhere. Or maybe my case is very unique. Any advice is appreciated.

Feature request
Status

Needs review

Version

2.0

Component

Recurring Events Registration (Submodule)

Created by

🇨🇦Canada endless_wander

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024