Home > Impersonal > Wordpress plugin Contact Form 7 and line breaks

Wordpress plugin Contact Form 7 and line breaks

February 18th, 2009

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.

Aidan Findlater Impersonal , ,

  1. Andrew
    February 19th, 2009 at 10:32 | #1

    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!

  2. February 19th, 2009 at 10:56 | #2

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

  3. Ali
    April 29th, 2009 at 03:02 | #3

    Thank you!

  4. June 24th, 2009 at 17:39 | #4

    Any solutions for allowing the Success Message to support HTML?

  5. Nicholas Pufal
    December 24th, 2009 at 13:49 | #5

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

    And WPCF7_AUTOP is TRUE.

  6. January 15th, 2010 at 00:41 | #6

    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.

  1. March 7th, 2009 at 23:00 | #1