This occurs because CF7 now adds <p> tag on every line return.
You can disable this behaviour :
- open your
wp-config.php file in the WordPress root installation directory.
- add a line with
define('WPCF7_AUTOP', false ); in the beginning of the file.
WPCF7_AUTOP is an official constant of CF7, you can learn more here : https://contactform7.com/controlling-behavior-by-setting-constants/
Hi Vanoisbe I had the same problem as Mudassir but adding that line of code to the wp-config.php file did nothing.
The only place it works is if you change the code in wp-contact-form-7.php from true to false. (Which is a temporary solution at best)
Hi @lepapefrancois,
This option worked for me. Thank you for saving my day.
Dear @kimcoetzee,
Will give a try of your option on my other site and test will test if it works.
Thank you.
Hello @engrmhk,
Did you checked the same problem with email? if you have stylist email which is send when form is submit then you will find huge spaces under the email also. the <p><br></p> tags also include under the mail code.
As “define(‘WPCF7_AUTOP’, false );” successfully resolved the problem of form frontend but how we can remove <p> tags from mail?
please help if anyone resolved this issue.
This problem comes in 5.7 version, the older version 5.6.4 was just perfect.
Well, I think adding a <p> tag for every new line is not a good idea, because a lot of my themes have cf7 integrated, and the design breaks as soon as I change even a line of code.
Asking every user to add define(โWPCF7_AUTOPโ, false ); in wp-config is pretty hard for people with no code experience.
Please get back to the previous version.
Hi,
Try putting the below code on functions.php.
add_filter(‘wpcf7_autop_or_not’, ‘wpcf7_autop_return_false’);
function wpcf7_autop_return_false() {
return false;
}
@arafatjamil01
Asking every user to add define(โWPCF7_AUTOPโ, false ); in wp-config is pretty hard for people with no code experience.
Totally agree!
I spent half a day, changing 50+ website wp-config.php yesterday… At least, it will be set for the next update. I don’t know why there is not already a new upgrade of the plugin…
This fixes the contact form but breaks the page.
“open your wp-config.php file in the WordPress root installation directory.
add a line with define(‘WPCF7_AUTOP’, false ); in the beginning of the file.”
Hi @arafatjamil01, Agree with you. Asking everyone to do so is not an easy job and the as most people are not pro, so they face a lot of issues while fixing it.
Having the same issues, why has this default behaviour changed?
Can this be regressed please to avoid the need to roll-back/update many sites.
Thx
@shozoon – Thanks, this worked for me. Here is an even lighter weight code to add to functions.php.
add_filter('wpcf7_autop_or_not', '__return_false');
@riseofweb – Ah, okay. Thank you!
-
This reply was modified 3 years ago by
shozo.
While poking into code files can be understandably unnerving to the uninitiated, I agree the larger issue is the maintenance aspect. Not only will it take a lot of time to make the change on many sites but wouldn’t it get overwritten by a WordPress update? The better solution would be to create a toggle control for autop as an option in the settings of the plugin, would it?