Remove empty fields from customize email content.

Home Forums Quform WordPress Remove empty fields from customize email content.

This topic is: resolved
Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #7765
    yanivmirel
    Participant

    Hi,

    Is there a way to hide/remove empty fields within the customize email content.
    When I am creating the html content I am inserting all fields variables because I can’t tell which one the client will fill up.
    But I really need to hide the empty ones from my email (I have more than 100 inputs)

    Thanks.

    #7771
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #7785
    yanivmirel
    Participant

    And I do I add the entry ID to that html/php?
    Is this the correct way to add date and time separate.
    Date: <?php echo date(‘d/m/Y’); ?>, Time: <?php echo date(‘H:i’); ?>

    Thanks for great support

    #7786
    yanivmirel
    Participant

    My HTML will be a huge table.
    Do I need to wrap the code above in <?php …… ?>
    Can you give an example of how to wrap the if statement.
    Here is a section of my HTML.

    <table dir=”rtl” border=”1″ align=”center” style=”width: 600px;margin:0 auto;”>
    <tbody>
    <tr>
    <th colspan=”2″ style=”text-align: right;”>Client info</th>
    </tr>
    <tr>
    <td>Name</td>
    <td><?php echo $form->getValueHtml(‘iphorm_1_1’); ?></td>
    </tr>
    <tr>
    <td>Did you work with us before</td>
    <td><?php echo $form->getValueHtml(‘iphorm_1_120’); ?></td>
    </tr>

    Thanks

    #7803
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #7822
    yanivmirel
    Participant

    Hi,

    Once I am done with that, do I need to set something in the admin.
    like Unchecking “Customize email content” or something…..?

    Will the plugin know to submit it from the new function instead?

    #7823
    yanivmirel
    Participant

    Can you also reply to my other question #7785 ?

    #7824
    yanivmirel
    Participant

    One last question.
    The same if statement (->isEmpty()) is good to check Boolean field?

    #7833
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #7836
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #7985
    yanivmirel
    Participant

    Hi,

    I have a field with a radio select, how to I check for the value with the if statement.
    something like: <?php if (!$form->getElement(‘iphorm_1_120’) == ‘yes’) : ?>
    when ‘yes’ is the value.

    is this the correct way?

    #7988
    josef777
    Participant

    Yaniv

    Do the following because you are doing it the hard way :

    see the following guides

    Custom autoreply content

    Custom email content

    1-open autoreply-content.php and Modify iphorm_1_2 and iphorm_1_1 to the ids from your form (those are Title and Name in my form ) and edit the text at the top to whatever you wish , do not do anything to the rest of the code (it’s from email-html.php, just changed the style).

    2- Follow the guides above for the functions.php

    Now go and test it !

    autoreply-content.php
    Dear <?php echo $form->getValueHtml('iphorm_1_2'); ?> <?php echo $form->getValueHtml('iphorm_1_1'); ?><br /><br />

    below is your submission to your company , thank you in advance and we will get in touch with you shortly .<br /><br />

    Best Regards<br />
    Your Company<br /><br />

    Phone : +43 000 000 000<br />
    Email : office@yourdomain.com<br />
    Website: http://yourdomain.com<br />
    --------------------------------------<br />

    <table width="600" cellpadding="0" cellspacing="0" border="0" style="font: 14px Helvetica, Arial, sans-serif;">
    <tr>
    <td valign="top" style="font-family: Helvetica, Arial, sans-serif; font-size: 20px; font-weight: bold; color: #282828; padding-bottom: 10px;"><?php echo esc_html($mailer->Subject); ?></td>
    </tr>
    <tr>
    <td valign="top"><table width="100%" border="0" cellpadding="2" cellspacing="0" style="border-collapse:collapse;">
    <?php
    $elements = $form->getElements();
    foreach ($elements as $element) : ?>
    <?php if (!$element->isHidden() && (!$element->isEmpty() || ($element->isEmpty() && $form->getNotificationShowEmptyFields()))) : ?>
    <?php if ($element instanceof iPhorm_Element_Groupstart) : ?>
    <?php if ($element->getShowNameInEmail() && strlen($adminTitle = $element->getAdminTitle())) : ?>
    <tr>
    <td colspan="2" valign="top" style="border: 1px solid #F0F0F0;font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; color: #282828; padding-top: 15px; padding-bottom: 10px;"><?php echo esc_html($adminTitle); ?></td>
    </tr>
    <?php endif; ?>
    <?php else : ?>
    <tr>
    <th scope="row" style="font-size: 12px;border: 1px solid #F0F0F0;padding: 10px;text-align: left;vertical-align: top;width: 150px;"><?php echo esc_html($element->getAdminLabel()); ?></th>
    <td style="border: 1px solid #F0F0F0;font-size: 12px;line-height: 20px;margin-bottom: 9px;padding: 8px 10px;">
    <?php echo $element->getValueHtml(); ?>
    </td>
    </tr>
    <?php endif; ?>
    <?php endif; ?>
    <?php endforeach; ?>
    </table></td>
    </tr>
    </table>

    email-content.php
    <?php if (!defined('IPHORM_VERSION')) exit; ?><html>
    <body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">
    <table width="600" cellpadding="0" cellspacing="0" border="0" style="font: 14px Helvetica, Arial, sans-serif;">
    <tr>
    <td valign="top" style="font-family: Helvetica, Arial, sans-serif; font-size: 20px; font-weight: bold; color: #282828; padding-bottom: 10px;"><?php echo esc_html($mailer->Subject); ?></td>
    </tr>
    <tr>
    <td valign="top"><table width="100%" border="0" cellpadding="2" cellspacing="0" style="border-collapse:collapse;">
    <?php
    $elements = $form->getElements();
    foreach ($elements as $element) : ?>
    <?php if (!$element->isHidden() && (!$element->isEmpty() || ($element->isEmpty() && $form->getNotificationShowEmptyFields()))) : ?>
    <?php if ($element instanceof iPhorm_Element_Groupstart) : ?>
    <?php if ($element->getShowNameInEmail() && strlen($adminTitle = $element->getAdminTitle())) : ?>
    <tr>
    <td colspan="2" valign="top" style="border: 1px solid #F0F0F0;font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; color: #282828; padding-top: 15px; padding-bottom: 10px;"><?php echo esc_html($adminTitle); ?></td>
    </tr>
    <?php endif; ?>
    <?php else : ?>
    <tr>
    <th scope="row" style="font-size: 12px;border: 1px solid #F0F0F0;padding: 10px;text-align: left;vertical-align: top;width: 150px;"><?php echo esc_html($element->getAdminLabel()); ?></th>
    <td style="border: 1px solid #F0F0F0;font-size: 12px;line-height: 20px;margin-bottom: 9px;padding: 8px 10px;">
    <?php echo $element->getValueHtml(); ?>
    </td>
    </tr>
    <?php endif; ?>
    <?php endif; ?>
    <?php endforeach; ?>
    </table></td>
    </tr>
    </table>
    </body>
    </html>

    • This reply was modified 10 years, 4 months ago by josef777.
    #7992
    yanivmirel
    Participant

    Hi Josef,

    Thank you for your answer but it’s not that simple with my form.
    My form has 11 different sections with total of 150 elements when 45 of them are based on conditional fields.
    My email content is organized with table headers for each section and so on and so on….
    I already finish with the hard job (I guess I did it the hard/long way).
    I just need to not include few elements based on other elements radio choices.

    I will appreciate if you can answer my last question (#7985)

    Thanks

    #7993
    josef777
    Participant

    1- it’s up to you but it doesn’t matter how many sections or fields you have or whether they have conditional logic or not , the above files will hide empty fields and email what been selected .

    2- (#7985) You have to wait for Ally , my php is very limited 🙂

    #8025
    yanivmirel
    Participant

    Any news from the support staff?

Viewing 15 posts - 1 through 15 (of 19 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy