I am trying to put some logic into user registration welcome emails. Simple "if-then" logic, based on tokens.
The tokens I use show up as expected, but both twig and php code gets sent as plain text.
Can I somehow make twig or php code execute before the email is sent to the new user?
UPDATE, to make the question more specific:
I have token module enabled.
I am trying to add this logic to the welcome email sent to new users at "/admin/config/people/accounts":
{% if [user:field_marketing_package] == "Yes" %}
<p>Marketing selected</p>
{% endif %}
The [user:field_marketing_package] field is filled out at user registration.
I would like to add logic like this. If I have the above twig code in the message, it just gets sent as plain text and does not execute.
Twig or php or any other solution is fine as long as I can include the token in the if statement.
Can you point me to the right direction?
hook_mail()
api.drupal.org/api/drupal/core%21core.api.php/function/… orhook_mail_alter()
api.drupal.org/api/drupal/core%21core.api.php/function/… for adding arbitrary information to automatically generated emails. User notifications have the account in question in their parameters. So you can access this information through the$params
argument/'params'
message array key.