Wordpress plugin Contact Form 7 and line breaks

9 Comments

Summary: Contact Form 7, a Wordpress plugin, automagically adds line breaks (<br />) to the outputted HTML. To disable it, set define(‘WPCF7_AUTOP’, false); in wp-contact-form-7.php. Problem: When setting up the contact form, the plugin added line breaks between <a> and <span>, which interfered with the CSS layout and styling of the form.

Solution: In the plugin’s folder, the file wp-contact-form-7.php has (line 53):

if (! defined('WPCF7_AUTOP'))
    define('WPCF7_AUTOP', true);

Changing the second line from ‘true’ to ‘false’ corrects the unexpected behaviour.

Discussion: The plugin developers obviously recognized that not everyone would want their posts auto-formatted, which is nice. Unfortunately, it isn’t a very well-documented feature.

Edit (2010-05-24: As per the CF7 documentation, the constant should be defined in wp-config.php, not wp-contact-form-7.php as above.

Andrew

Superb! This fixed a major difficulty that we were having with an ultra-long form.

(On a side note, do you mean changing ‘true’ to ‘false’ to correct the auto-formatting?)

Thanks again!

2009-02-19 10:32 am

aidan

You’re right, I copied and pasted after I changed it. It’s fixed now, thanks.

2009-02-19 10:56 am

Blog Archive : First contact : irama.org

[…] workaround has been suggested, thanks […]

2009-03-07 11:00 pm

Ali

Thank you!

2009-04-29 3:02 am

Jfisher

Any solutions for allowing the Success Message to support HTML?

2009-06-24 5:39 pm

Nicholas Pufal

ENTER is not breaking the text here. I receive everything inline in my mail program.

And WPCF7_AUTOP is TRUE.

2009-12-24 1:49 pm

Ash Blue

O thank God, this saved me a lot of poking around. I can see how having this would be a quick and simple solution for the average Joe using this form. Not for those who hand craft CSS though.

2010-01-15 12:41 am

Diane

This is exactly what I need! thx

2010-05-03 2:50 am

Jules

I tried updating WPCF7_AUTOP to false in wp-contact-form-7.php with no luck. I even tried updating it through the wp-config.php file but I still got those darn tags.

Any suggestions?

2010-05-20 11:04 pm