Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Jacob Roman
22,640 PointsWordpress Contact Form 7 Hiding Empty Fields in email.
Hello,
I am using contact form 7 and have a long form with lots of text fields. I am looking for a way to only show fields that the user fills out in the email. I came across this link:
But it does not quite work for me because I have my email body set up like this:
<table>
<tr style="border:1px solid;">
<th style="background:#000; color:#fff;">Item</th>
<th style="background:#000; color:#fff;">Qty</th>
</tr>
<tr style="border:1px solid #ccc;">
<td>Aerobic Culture Swab</td>
<td>[AerobicCultureSwab]</td>
</tr>
<tr style="border:1px solid #ccc;">
<td>Alcohol Prep Pad</td>
<td>[AlcoholPrepPad]</td>
<tr style="border:1px solid;">
<tr>
So i need the parent tr to hide if the field is empty. Any suggestions?
I hope that makes sense.
2 Answers

Matthew Harding
3,099 PointsWell first you need to use a form tag and then the input tags within the form tags . With this you can then use php to get the data and see whether the data was filled out and not filled out

Jeremy Menicucci
19,227 PointsI'm assuming you could probably wrap the parent tr in a conditional something like:
if ($variable != " ") {
<tr style="border:1px solid;">
<th style="background:#000; color:#fff;"><?php echo $variable; ?></th>
</tr>
}