• Hello,

    Due to the update a few months back we had to add add_filter( ‘wpcf7_autop_or_not’, ‘__return_false’ ); to various of our websites to resolve additional p tags which were added on the front-end which messed up some of the form layouts.

    But one issue we have now is that this doesn’t only impact the front-end form output, it also affects the html within the form response sent by email, so we have a fair few responses now rendering the response all on one line vs. adding br tags like it did previously.

    With this in mind, is there a way to adjust the hook add_filter( ‘wpcf7_autop_or_not’, ‘__return_false’ ); so that this only applies to the front-end form output, but not to the form response sent by email?

    Many thanks for your help,
    Tonya

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,
    I was able to do it in the following way.


    remove_filter( ‘wpcf7_mail_html_body’, ‘wpcf7_mail_html_body_autop’, 10 );
    function bs_wpcf7_mail_html_body_autop( $body ) {
    return wpcf7_autop( $body );
    }
    add_filter( ‘wpcf7_mail_html_body’, ‘bs_wpcf7_mail_html_body_autop’, 10, 1 );

    The point of the tweak is that string breaks will always be added for email, regardless of the WPCF7_AUTOP constant. This will not affect the output of the forms themselves.

    Since version 5.8.6 this is possible. The filter got a new option:

    See: https://github.com/rocklobster-in/contact-form-7/commit/68303ab47a24907e9364e227c9a3a104650f4188

    Instead of:

    add_filter( 'wpcf7_autop_or_not', '__return_false' );

    You can use:

    // For form output.
    $options = array( 'for' => 'form' );
    add_filter( 'wpcf7_autop_or_not', '__return_false', $options );

    or

    // For mail.
    $options = array( 'for' => 'mail' );
    add_filter( 'wpcf7_autop_or_not', '__return_false', $options );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wpcf7_autop_or_not help’ is closed to new replies.