• Resolved philrp

    (@philrp)


    Hello

    I’ve been using CF7 for years with a large form made up of <div> tags to form a table, associated with a response email that uses <table><tr><td>

    When I upgraded from 5.6.4 to 5.7.7, CF7 inserted <p> tags in each table cell. I removed them by adding define( ‘WPCF7_AUTOP’, false ); to wp-config. php.

    This removed the <p> tags from the form, but they are still being inserted in the response email.

    Any way to remove the <p> tags from the mail? Any help would be appreciated

    Thanks

    • This topic was modified 1 year, 5 months ago by philrp.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter philrp

    (@philrp)

    After much digging, I realized that this issue has been around since 5.7 and though best to update here… for the next people

    From original poster icodina?

    Solution for the form:

    wp_config.php: define('WPCF7_AUTOP',false);
    functions.php: add_filter('wpcf7_autop_or_not','__return_false');

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

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

    Hey!

    My issue was that I did not want it to affect the HTML body of the sent emails and it was doing it in 5.8.

    It seems like your issue has been fixed in 5.8 but I had no idea it was intended to also affect the HTML body since it didn’t in 5.7.7.


    My solution to NOT affect the HTML body without changing the plugin itself. I am using the filter conditionally in functions.php.

    function disable_wpcf7_autop_for_display() {
        // Only add the filter if we're not in the middle of sending the mail
        if (!doing_action('wpcf7_before_send_mail')) {
            add_filter('wpcf7_autop_or_not', '__return_false'); //Remove p and br tags in forms
        }
    }
    add_action('template_redirect', 'disable_wpcf7_autop_for_display');

    I wasn’t sure how this will behave with concurrent users and I have tested it to a degree and it seems to not interfere with or be affected by concurrent users.

    • This reply was modified 1 year, 3 months ago by axellerater.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘p tag in mail since 5.7.7, despite WPCF7_AUTOP, false’ is closed to new replies.