WordPress.org

Forums

Contact Form 7
[resolved] Remove empty values from Contact Form email (5 posts)

  1. ojje
    Member
    Posted 8 months ago #

    I have a lot of fields in a Contact Form.
    All fields are included in the email.
    I need to remove fields with empty values from email.

    https://wordpress.org/plugins/contact-form-7/

  2. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 8 months ago #

    Check "Exclude lines with blank mail-tags from output" box in the Mail section.

  3. ojje
    Member
    Posted 8 months ago #

    Thanks for your reply!
    Unfortunately it wont work just to check the "Exclude lines with blank mail-tags from output" box in the Mail section.

    The problem is that the form will have a large amount of fields and to make it easier to read the email I want to only add the fields where the user has entered a value.

    If the user choose to enter 10 for Pizza and 10 For Cola I just want the email to
    show Pizza: 10 and Cola: 10.
    So I need to exclude the labels as well if the value is empty if its possible.

    My email template looks like this:

    {Food}
    --
    Hamburgers:
    [Hamburgers]

    Pizza:
    [Pizza]

    Taco:
    [Taco]

    {Drinks}
    --
    Cola:
    [Cola]

    Fanta:
    [Fanta]

    Sprite:
    [Sprite]

  4. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 8 months ago #

    Put both the label and the value in one line.

  5. ojje
    Member
    Posted 8 months ago #

    Perfect, it works!
    Thanks a lot for your help! =)
    And thanks a lot for your work with the contact form plugin!

Reply

You must log in to post.

About this Plugin

  • Contact Form 7
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic