Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1486540

    is there any way to add <br/>‘s and <strong>‘s in the email that is generated from the contact form submissions withOUT having to alter theme file(s)???

    would be nice to bold the field labels & colons and also add an extra line break between them in the emails.

    if it can’t be done without modifying any theme files (unless it can be a Child Theme file?), then nevermind. but please put it in a wishlist for future versions. to have something in the Enfold settings interface where we could customize how the emails look (no matter how many form fields or labels it has).
    thanks.

    #1486561

    Hey syberknight-tb,

    Thank you for the inquiry.

    Unfortunately, there is no built-in option for this. You can try using the avf_form_message filter to modify the message content, but adding html may not work as expected.

    add_filter('avf_form_message', 'avf_form_message_mod', 10, 3);
    function avf_form_message_mod($message, $new_post, $form_params) {
        // do something with the message here
        return $message;
    }
    

    We recommend using advanced contact form plugins such as WPForms, Contact Form 7, or Gravity Forms.

    Best regards,
    Ismael

    #1486717

    hi Ismael,

    i’ve been playing around with this a little as i can and have some followup thoughts/questions/info for you…

    in your message above, you said “adding html may not work as expected“.
    – would you elaborate on that please?
    – how would it not work?
    – is it really not worth trying to bold the element & colon, and add a space between each in the email?
    – if it’s not likely to work across the board, then i don’t want to mess with it. but if making those 2 modifications can work in all email apps & browsers, then i’m game to try figuring it out. i need it to be rock-solid (as solid as anything else the theme does).

    IF” your response to that is positive, then please continue.
    IF” your response to that is negative, then nevermind & thank you! (although, please do see the end about the bug i found).

    in your function code snippet above, i see your comment to “do something with the message here/“.
    – but i have no idea what to put there.
    – i found similar code @…
    kriesi.at/support/topic/using-the-universal-wp-lead-tracking-plugin-with-enfold-contact-form
    …but the only part that looks familiar is the “\n” part.
    – i found some other similar code @…
    kriesi.at/support/topic/contact-form-html-field
    …but again, not enough info/examples for me to craft something to fit my use-case.

    i then ran across some posts advising folks to edit the theme file…
    /enfold/framework/php/class-form-generator.php
    1) i do NOT want to mess with the theme files at all (for obvious reasons);
    2) i did look thru it (again, not really knowing php), and see on line 1559, there’s html code, adding some <br/> and <strong> tags to the “Your Message:” part of the email. i wondered if there’s a way to customize all email elements using that “avf_form_message” filter.
    – so no matter what “Form Element Type” is used, the “Form Element Label” with colon would be bolded, and an empty space (hard return, \n) would be between all Elements in the email.

    lastly, i discovered the “Other Element: Empty Line” Form Element Type!
    thinking this may at least solve the issue of getting some space between the form types in the emails, so i added it and set it for “Print in e-mail only”.
    – testing it does in fact add the spacing i was hoping for in the emails,
    …BUT, YOU SHOULD KNOW…
    there’s a bug in that even tho it’s set for “Print in email only” it still also adds it to the front-end webpage.

    …when testing, all my elements with 1/2 width styling gets broken into individual lines.
    – so unfortunately, i can’t use this cool discovery until that gets fixed in the theme.

    note: additionally, the “Message” element already has an extra space above it, so putting that empty element above it produces 2 blank lines in the email. would be nice to either have the spacing consistent for all element types or add a note about that in the form settings.

    thanks for the help.

    #1486718

    Hi,

    Thank you for the update.

    We simply mean that it may not work on email clients that do not support html. They should render correctly on major email clients such as Gmail or Outlook. You can test this by using the following filter in the functions.php file, sending a message, and checking whether the heading and test strings render properly with the html formatting applied.

    add_filter('avf_form_message', 'avf_form_message_mod', 10, 3);
    function avf_form_message_mod($message, $new_post, $form_params) {
        $message = "<h1>Heading</h1><strong>TEST</strong>" . $message;
        return $message;
    }
    

    – but i have no idea what to put there.

    You can manipulate the content of $message as shown in the previous examples. You can inject html into specific parts of the text or prepend/append additional content to the message. Unfortunately, this level of customization is beyond the scope of our support. If you’re not sure how to proceed, consider hiring a freelance developer or contact Codeable.

    https://kriesi.at/contact/customization

    Regarding the issue with “Print in email only”, which email client are you testing this with? Try to add the following code to the functions.php file to remove al line breaks from the message:

    add_filter( 'avf_form_mail_form_field', 'avf_form_mail_form_field_mod', 10, 7 );
    function avf_form_mail_form_field_mod( $form_field, $new_post, $form_elements, $form_params, $element, $key, $field_value ) {
        $form_field = preg_replace( '#<br\s*/?>#i', '', $form_field );
        return $form_field;
    }
    

    Best regards,
    Ismael

    #1486772

    hi Ismael,
    thank you for your time on this. i understand about it being out of scope.

    about the last part tho – maybe i didn’t explain very well. when i use the ‘Print in email only”, it DOES work in the email. the problem is it also puts it in the webpage front-end.

    so in this scenario, i create a contact form in the builder.
    i have 2 Elements to show side-by-side on the webpage front-end by changing their style width to 1/2.
    then add the Empty Line Element in between those Elements,
    set it to use only in the email so they have some separation in the email, not the webpage.

    but for some reason when i set it like this, it ALSO puts the break between the two 1/2’s in the webpage front-end.
    does that make sense?

    #1486776

    Hi,

    i have 2 Elements to show side-by-side on the webpage front-end by changing their style width to 1/2.

    The reason the elements got split is that the empty line adds a br tag even on the frontend. The filter we provided above should remove those line breaks. Try to avoid placing the empty line element within rowed elements.

    Best regards,
    Ismael

    #1486949

    hi Ismael,

    i added your avf_form_mail_form_field_mod function code, and it does indeed strip all the BR’s from the email.

    so then i went in & added the Empty Line Elements between each element.

    this still breaks the front-end even tho all the Empty Line Elements are set to Print in email only.

    i went ahead & tested the form and i guess that function code overrides the Empty Line elements, because the resulting email was without any line breaks.

    so i guess i’m just gonna have to go back to the default email formatting.

    i’m not understanding, tho, if the Empty Line Elements are set to Print in email only, why it adds BR’s in the front-end. that’s why i think this is a bug, because to me, if it says it’s only for the email, then it should only be in the email & not affect the front-end at all.

    #1486961

    Hi,

    Yes, it’s only for print, but the empty line item still renders a blank space, breaking the markup of the rowed elements and splitting them. This is why we recommend to avoid placing empty lines between rowed or columned elements to prevent breaking the layout. Hope this clear things up a bit.

    Best regards,
    Ismael

    #1486992

    then why give an option to have a BR in email only if it’s also gonna add it to the front-end?

    #1487055

    Hi,

    Have you tried placing it in a different location, not between the rowed or columned elements? Do you notice any changes? What we’re trying to explain is that the empty line should remain truly invisible, but placing it between rowed or columned elements could break the layout.

    Best regards,
    Ismael

    #1487087

    hey,
    i made an annotated screenshot – hopefully it will appear below & help explain what i mean better.

    looks like the “Empty Line” Element, when set to “Print Email Only” is adding a “first_form” class to any field that doesn’t already have it. and that class seems to be the reason that it breaks a row on the front-end.

    so seems to me that the “Email Only” “Empty Line” needs to stay email only and not add that class to fields on the front-end.

    hope that helps. i don’t mean to beat a dead horse, so you can close this topic if you want. doesn’t seem to me that there’s anything else to be done until/unless ya’ll change that (to me, bug) issue so when an element is set for email only, it doesn’t change anything on the front-end.

    screenshot showing the issue here

    #1487099

    Hi,

    The addition of the class first_form when the empty line is present is expected since the third form field (phone) is technically the first field in the new row. The empty line counts as a field, at least in how it’s rendered in the document, so the layout works as follows: first row – 1/2 field (email) + empty line; second row – 1/2 field (phone). This can be avoided by removing the empty line and using it only before or after full-width elements.

    If you need to force the phone field to stay in the second row even when there’s an empty line in between, try adding this css code:

    #top .avia_ajax_form p#element_avia_2_1, #top .avia_ajax_form p#element_avia_4_1 {
        clear: none !important;
        float: left;
        margin-left: 0;
    }
    
    #top .avia_ajax_form p#element_avia_4_1 {
        margin-left: 1%;
    }
    

    Best regards,
    Ismael

    #1487131

    hi again,
    i hear you. so, what you’re telling me is that what i’m reporting is NOT a bug, but intentional?
    then would you please remove the wording that the empty line element, when set to print email only is NOT “email only”?

    that’s the part that doesn’t make sense. why say it’s for email only when it’s not for email only?
    if it was truly for email only, then it would make zero changes on the front-end.

    i appreciate your replies but i’m feeling like we aren’t understanding each other. if that’s my fault, i apologize, and don’t know what else to say.

    #1487142

    Hi,

    It’s not a bug, maybe just a misunderstanding of how it should be used due to the lack of element description. This is the code for the empty_line element, which returns nothing when $element['element_display'] is set to "e-mail". As mentioned above, try to avoid using the empty_line element between columned or rowed elements.

    /**
    		 *
    		 * @since 4.8.6.4
    		 * @param string $id
    		 * @param array $element
    		 */
    		protected function empty_line( $id, array $element )
    		{
    			if( isset( $element['element_display'] ) && 'e-mail' == $element['element_display'] )
    			{
    				return;
    			}
    
    			$this->elements_html .= "
    <p id='element_{$id}' class='{$element['class']} av-form-empty-line '></p>
    
    ";
    		}
    

    Please feel free to open another thread if you have more questions.

    Thank you for your patience.

    Best regards,
    Ismael

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Customize the Contact Form EMAIL’ is closed to new replies.