2

According to the Contact Form plugin docs, I can do:

<input type="hidden" name="toEmail" value="{{ '[email protected], [email protected]' | hash }}">

That seems to work fine, but one of those email addresses I want to add dynamically. I've tried the following, but none seem to work, generally sending to just the second email address:

{# adding first email as var #}
{% set firstEmail = '[email protected]' %}
<input type="hidden" name="toEmail" value="{{ firstEmail ~ ', [email protected]' | hash }}">%}

{# adding first email as var and avoiding | hash #}
{% set firstEmail = '[email protected]' %}
<input type="hidden" name="toEmail" value="{{ firstEmail ~ ', [email protected]' }}">%}

{% set firstEmail = '[email protected]' %}
{% set emails = firstEmail ~ ', [email protected]' %}
<input type="hidden" name="toEmail" value="{{ emails | hash }}">
{# RESULT: <input type="hidden" name="toEmail" value="[email protected], [email protected]">#}

{# adding first email as var with extra quotes #}
{% set firstEmail = '[email protected]' %}
{% set emails = "'" ~ firstEmail ~ ", [email protected]'" %}
<input type="hidden" name="toEmail" value="{{ emails | hash }}">
{# RESULT: <input type="hidden" name="toEmail" value="e3a44b3632212521351d8d44af34742a63f6516e'[email protected], [email protected]'"> #}

Any ideas?

4
  • Missing the quotes around the email addresses?
    – carlcs
    Commented Jun 30, 2016 at 8:32
  • Sorry, I've put those back in. I've added a fourth example as well. Commented Jun 30, 2016 at 9:02
  • Hmm.. your 3rd example should actually work now.
    – carlcs
    Commented Jun 30, 2016 at 9:45
  • That's what I thought. I've added the output of that third example. Commented Jun 30, 2016 at 11:29

1 Answer 1

1

Both, the example from the Contact Form docs

{{ '[email protected],[email protected]'|hash }}

...and the 3rd example snippet in your question

{% set firstEmail = '[email protected]' %}
{% set emails = firstEmail ~ ',[email protected]' %}

{{ emails|hash }}

...output exactly the same string for me! So I think you have to search for an answer to your issue elsewhere.

1
  • FWIW this syntax should also work (firstEmail ~ ',[email protected]')|hash, first cancat and then apply the filter.
    – carlcs
    Commented Jun 30, 2016 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.