PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Insert HTML into notification emails

  1. Hello,

    I'm pulling data in from one form and inserting it (ready formatted) into a html field on a second form. I then want this html field to go into the notification email that gets sent from the second form.

    I saw that someone was using the Gravity Forms Terms of Service Field plugin to achieve something similar, and this is close, but the field displays the encoded html. I could get round this by still using the html field still, and just using the TOS field for the email but it seems to strip it out all of the html when it is sent.

    Is there a way of inserting HTML into the notification emails?

    Thanks,
    James

    Posted 11 years ago on Monday October 8, 2012 | Permalink
  2. The notification emails are normally formatted in HTML, unless you change them. However, HTML is not allowed in form entries by default. If you would like to allow HTML be submitted by your visitors, please see gform_allowable_tags to allow specific HTML in your entries.

    http://www.gravityhelp.com/documentation/page/Gform_allowable_tags

    Posted 11 years ago on Monday October 8, 2012 | Permalink
  3. Thanks Chris.

    Ideally I don't want to allow HTML to be submitted - I just want to be able to get HTML into the notification after form submission. I couldn't see a hook that would allow me to do this though.

    The emails are in HTML format - I'm guessing my content is just getting html stripped because I'm inserting it by filling a field on submission, and as you say html is not allowed.

    I just need a way to get html into the email... Is the only way to allow html in fields?

    Thanks,
    James

    Posted 11 years ago on Monday October 8, 2012 | Permalink
  4. Can you post links to the pages where your forms are embedded? I'm having a hard time visualizing the flow. Maybe even post at pastie.org or pastebin.com the text of an email notification? And what are you actually using now, the TOS plugin or just an HTML field?

    I'm guessing my content is just getting html stripped because I'm inserting it by filling a field on submission, and as you say html is not allowed.

    I believe that is true.

    Is the HTML being stored properly in the entry? If so, we may be able to modify the user notification after and just add this HTML field to it. However, if it's not stored correctly, we will have to come up with another solution.

    Posted 11 years ago on Monday October 8, 2012 | Permalink
  5. Hi, James,

    I think what you really need to use is the gform_pre_submission_filter (http://www.gravityhelp.com/documentation/page/Gform_pre_submission_filter) . This filter allows you to modify the email body content. You can set the content to the value from the HTML field. See the example located at http://pastie.org/5021159 . You will see that I am setting the message for the admin notification and the user email to the content of my html field (field id 1 in the example). I have responded to your priority ticket with the same information.

    Posted 11 years ago on Monday October 8, 2012 | Permalink
  6. Thank you both for your support.

    Dana,

    This fixes it perfectly. I was already using the pre_submission filter, I just needed to know that I could access the email message via $form["notification"]["message"].

    Did I miss this in the documentation?

    Thanks,
    James

    Posted 11 years ago on Tuesday October 9, 2012 | Permalink
  7. I found it in the documentation here:

    http://www.gravityhelp.com/documentation/page/Notification

    Clearly I need to work a bit harder on my search-fu.

    Thanks again,
    James

    Posted 11 years ago on Tuesday October 9, 2012 | Permalink
  8. Glad you got it working, thanks for letting us know!

    Posted 11 years ago on Tuesday October 9, 2012 | Permalink

This topic has been resolved and has been closed to new replies.