0

I'm trying to get Conditional Fields for Contact Form 7 up and running in WordPress. I'm using Contact Form 7 version 5.1.3 and Contact Form 7 Conditional Fields version 1.9.14.

I'm trying to follow this tutorial, which gives you the final code to paste into the Contact Form 7 Form tab:

Your name: [text your-name]
Your email address: [email* your-email]
<p>What kind of support do you want?
[select* support-type first_as_label "-- Choose support type --" "Technical support" "Sales"]</p>
[group technical-support-selected]
  <p>Your operating system: [select* operating-system first_as_label "-- Choose your operating system --" "Android" "iOS" "Linux" "Windows" "Other"]</p>
  [group os-selected]
<p>Please specify your [group os-android inline]Android[/group][group os-iOS inline]iOS[/group][group os-linux inline]Linux[/group][group os-windows inline]Windows[/group] version:
    [text* version]</p>
  [/group]
  [group os-other-selected]
    <p>Please specify your OS and version.
    [text* other-os "Operating System"][text* other-version "Version"]</p>
  [/group]
[/group]
[group sales-support-selected]
  <p>Where is your business located?
  [select* continent first_as_label "-- Choose your continent --" "Europe" "America" "Africa" "Asia" "Oceania" "Antarctica"]</p>
[/group]

<p>[textarea comments]</p>

[submit "Send"]

and this code to paste into the Conditional Fields tab in Text view:

show [technical-support-selected] if [support-type] equals "Technical support"
show [sales-support-selected] if [support-type] equals "Sales"
show [os-selected] if [operating-system] not equals ""
               and if [operating-system] not equals "Other"
show [os-android] if [operating-system] equals "Android"
show [os-iOS] if [operating-system] equals "iOS"
show [os-linux] if [operating-system] equals "Linux"
show [os-windows] if [operating-system] equals "Windows"
show [os-other-selected] if [operating-system] equals "Other"

However, when I paste the code in, the final output isn't hiding anything and [/group] shows through to the output. Here's a screen grab:

enter image description here

Any idea how I can get this working?

4
  • I'd try removing most of the conditional sections and adding them back in one by one to work out which one is causing the problems. I'd guess it's the <p>Please specify your [group os-android inline]Android[/group] line as that isn't choosing which device name to display correctly.
    – Rup
    Nov 28, 2020 at 11:42
  • But if you need expertise specific to that plugin you should probably ask the authors directly.
    – Rup
    Nov 28, 2020 at 11:42
  • Thanks, Rup. Given that that code is straight from the author's tutorial, I doubt it's something inherent in the code; more likely something to do with my set-up in some way that's not apparent to me. I did actually reach out to the author after posting this so hopefully he'll be able to reply soon.
    – Vincent
    Nov 28, 2020 at 23:13
  • Hopefully! But just because it's from official documentation doesn't mean it definitely works though - the documentation might be out of date, or it might have been broken by a bug since it was written.
    – Rup
    Nov 29, 2020 at 10:37

1 Answer 1

1

try adding the following code to your functions.php file,

add_filter( 'wpcf7_autop_or_not','__return_false');

the will remove the <p></p> wrapping tags added by the CF7 plugin for each new line in your form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.