• Since the 5.7 update, Contact Form 7 adds p tags in emails, breaking e.g. my table layouts in the email body. Looking at the code, I don’t see any option to disable wpcf7_autop for emails.
    mail.php:93
    $html = $header . wpcf7_autop( $body ) . $footer;

    Can you please add a filter so we can turn autop off for emails?

    Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • There’s the wpcf7_autop_or_not function that relies on WPCF7_AUTOP constant you can define in your functions.php however it doesnt fix for me

    Thread Starter thewebtailors

    (@thewebtailors)

    @frafor: Correct, there is wpcf7_autop_or_not filter and the WPCF7_AUTOP constant, but they seem to be only applied to the form output and not to the email.

    THIS IS VERY IMPORTANT
    $html = $header . wpcf7_autop( $body ) . $footer;
    It has broken all my html mails (in many websites)

    Thread Starter thewebtailors

    (@thewebtailors)

    Just in case someone wonders, Contact Form 7 5.7.1 still adds unwanted spaces into my HTML email (I am having a table within the email) and I could not find a filter to prevent that from happening. Still have to keep using 5.6.4 for right now…

    Provisional solution for the HTML mail:
    in line 93 the /wp-content/plugins/contact-form-7/includes/mail.php

    $html = $header.wpcf7_autop($body).$footer;
    CHANGE TO
    $html = $header.$body.$footer;

    Thread Starter thewebtailors

    (@thewebtailors)

    In case someone wonders, the issue still persists in Contact Form 5.7.2.

    Thread Starter thewebtailors

    (@thewebtailors)

    Unfortunately, also in version 5.7.3 p tags are automatically added to the email in places where they should not be. E.g. they are added to <td> elements inside a table:

    <table>
    <tbody>
    <tr><th>Name:</th><td>[your-name]</td></tr>
    <tr><th>Company:</th><td>[your-company]</td></tr>
    <tr><th>Email:</th><td>[your-email]</td></tr>
    <tr><th>Phone:</th><td>[your-phone]</td></tr>
    <tr><th valign="top" style="vertical-align:top">Message </th><td>[your-message]</td></tr>
    </tbody>
    </table>

    Please allow us to turn off/bypass the wpcf7_autop in the email. Or prevent <p> tags from being inserted into a table.

    Let me know if you have any questions. Thank you in advance for considering making these changes.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Add filter to disable wpcf7_autp for emails’ is closed to new replies.