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.

{all_fields} is there a way to control how this looks in an email?

  1. cowebdev
    Member

    Because I have conditional fields in the email the {all_fields} option works best because it does not show fields that were not used by the user..

    However, I would like the {all_fields} to change how it displays info.
    Instead of
    State
    Alabama

    I would like it to be
    State: Alabama

    Is it possible to modify the template it uses to create the table?
    I so how and where?

    I realize I could custom HTML everything, but then I would have to display field names that were not used and they would be blank in the cases where the conditions were not met to display those fields on the form...
    Unless there is a way to display text and fields conditionally in the email

    Posted 8 years ago on Tuesday August 2, 2011 | Permalink
  2. cowebdev
    Member

    this for email confirmations

    Posted 8 years ago on Tuesday August 2, 2011 | Permalink
  3. It does not appear that this is possible in the current Gravity Forms.

    If you format your confirmation manually, and an optional field is not submitted, there will not be a value in the HTML output, but the markup you hard coded into the confirmation would still be shown.

    Most complete answer I could find:
    http://www.gravityhelp.com/forums/topic/customizing-html-email-template#post-20286

    Posted 8 years ago on Tuesday August 2, 2011 | Permalink
  4. cowebdev
    Member

    What about , how the {all_fields} displays info?
    Can I modify that template

    Posted 8 years ago on Tuesday August 2, 2011 | Permalink
  5. I would not recommend modifying the core Gravity Forms plugin. Of course, you can, but it makes upgrading difficult.

    After I posted my last response I started looking into how to filter the confirmation email and I am working on some proof of concept code. I will post that within the hour if it works as expected. Thanks for your patience.

    Posted 8 years ago on Tuesday August 2, 2011 | Permalink
  6. There isn't a way (or easy way) to change the output of the {all_fields} merge code without hacking the core plugin files and you don't want to do that. That merge code was designed with "helper" styles for those who didn't want to spend a lot of time customizing their notification messages.

    The notifications allow HTML so you can use the individual field merge codes mixed with your own HTML markup to create your very own unique layout and styles. Go wild and create whatever layout you'd like. That's how the notification message settings were intended to work.

    Posted 8 years ago on Wednesday August 3, 2011 | Permalink
  7. @cowebdev I was able to work something out using the gform_pre_submission_filter filter. Here's the code I used:

    http://pastie.org/2315100

    Add that to your functions.php. Change the _12 on the end of the filter to match your form ID.

    Here's a test form where you can see it working in the confirmation you receive. Leave some of the fields blank to see if the heading still comes through in the notification email. Use your own email address to be sure you get the confirmation.

    http://gravity.chrishajer.com/testing-the-post/

    The code is commented and is hopefully self-explanatory. Please post if you need help getting it to work.

    Posted 8 years ago on Wednesday August 3, 2011 | Permalink
  8. shelzmike
    Member

    Great solution, though I have not tried it yet, but very straightforward. I had the exact same problem as the OP did here. Your solution looks straight-forward enough. However, i did have one question. Where can I find the input values of each field? (i.e. input_1_3, etc.)

    Once I figure that out, I will be unstoppable. :)

    Mike

    Posted 8 years ago on Monday August 22, 2011 | Permalink
  9. To find the specific field id's you would need to inspect the HTML output of the form. The id's will be visible in the form output as the id's for the inputs, etc.

    Posted 8 years ago on Monday August 22, 2011 | Permalink
  10. shelzmike
    Member

    Thanks for the info. So, I followed the instructions listed above and spent quite awhile coding (our form is an online web application that is really large - though I must say Gravity handles it very well!) and I am not getting the results I expected.

    Here is what I did:
    1.) Changed the 'gform_pre_submission_filter_1' (as this is form ID 1)
    2.) Created variables based on the ID's I got from inspecting the HTML using Firebug
    3.) Wrote the HTML for the email accordingly (and corresponding to the template given above)
    4.) Add this entire code to functions.php
    5.) Filled out another application as a test (cannot wait for 1.6 so that I can just resubmit :) )

    Here is what happened:
    I immediately got an email with the ORIGINAL formatting (blue/white/alternating table style that I am trying to change)

    Then, about 2 minutes later, I got an email of what looks like half of my custom HTML email. All of my regular text is showing; however, none of my variables are showing up.

    Here is the code: (bear in mind, this is still very rough, since it is the first iteration, I just used separate lines for each item to make tweaking easier. Then, I think I will go back and make it pretty).

    Here is the web url: http://www.webapps.acsdish.com/acs-employment-application

    Here is the code I wrote: http://pastie.org/2428578

    Here is the result that I got in email: http://pastie.org/2428594

    It appears as though it is just not pulling in the variables.

    Thanks!

    Mike

    Posted 8 years ago on Thursday August 25, 2011 | Permalink
  11. Looks like it's being processed for the correct form since you are getting your notification. It just doesn't have any variables.

    A couple things to test for. Can you see if the $_POST variable has values? You can do this by adding this code to you functions.php right inside your function. Put it at line 6 right before you try to grab all the variables.

    [php]
    wp_mail('youremail@gmail.com', 'POST variables from form 1 submission', print_r($_POST,TRUE));
    return $form;
    exit;

    Make sure that exit; is before line 7: "/ give the _POST variables more normal names". You just want to short circuit this function and see what the $_POST variable contains.

    That will dump the $_POST variable and email it to you. We need to see if it has all the values you need. If not, we need to figure out why. I can't find anything wrong with the code you posted.

    Posted 8 years ago on Thursday August 25, 2011 | Permalink
  12. shelzmike
    Member

    I appreciate your help here; however, I have decided to just simply use HTML in the Notification email settings in the dashboard. This works quite a bit better. I do have one more question though; (though not sure if I should paste it here or in another thread separately). I despise inline css as I have always used either an external style sheet or at minimum an internal style sheet. In this case, I would be interested in using an internal style-sheet over external. I know this goes in the head tag. Is the head tag for this email created from a function, or can I simply add the head tag in the notification customization area in the dashboard? Thanks!

    Mike

    Posted 8 years ago on Thursday August 25, 2011 | Permalink
  13. The header settings for the email is in code, in the common.php file. Currently there is no hook or filter for it.

    Posted 8 years ago on Thursday August 25, 2011 | Permalink

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