This plugin adds conditional logic to Contact Form 7.
If you edit your CF7 form, you will see an additional tag called “Conditional fields Group”. Everything you put between the start and end tag will be hidden by default.
After you added the field group(s), you should click Save.
Then you should go to the “Conditional fields” tab to create one or more conditions that will make the group(s) appear.
How to use it
A detailed example of how to use the plugin can be found here: http://bdwm.be/wpcf7cf/how-to-set-up-conditional-fields-for-contact-form-7/
Main/ New features
Compatible with Contact Form 7 Multi-Step Forms
Conditional Fields for Contact Form 7 is now fully compatible with Contact Form 7 Multi-Step Forms
Support for required fields
Required fields can be used inside hidden groups without causing validation problems.
Hide/show info in emails based on what groups are visible
Conditional groups can now be added to the emails as well.
Just wrap the content with
[group-name] ... [/group-name] tags.
Groups can be nested
Groups can be nested, both in the form and in the email
[group group-1] [group group-inside-1] ... [/group] [/group]
[group-1] [group-inside-1] ... [/group-inside-1] [/group-1]
Advanced users can now code up the conditions as plain text instead of using the select boxes, using the import/export feature.
Please follow the standard installation procedure for WordPress plugins.
- Installation Instructions
Please follow the standard installation procedure for WordPress plugins.
- Something isn’t working. Why?
I will assume that you successfully installed both plugins, that you were able to create some conditional groups, and that you managed to create some conditions. But for some reason it’s not working the way you expect it too. Here are the most common problems/causes people have encountered in the support forums. (Ordered from most frequent to least frequent.)
- All field names should be unique – Even though your fields might never show up at the same time, it is still important to realize that WPCF7CF will not remove the fields, it merely hides them. So all fields will be submitted when the form is sent. Because of this no two fields can have the same name.
Just wanted to say thanks for this awesome plugin. Saved us a lot of time, it worked flawlessly and it’s seamlessly integrated with Contact Form 7. Job well done!
Great that we finally have this functionality with CF7!!
Please keep it up to date in the future as well 😉
Amazing functionality and easy to use. In fact it’s so good that it should come standard with contact form 7. Seriously. My contact forms look clean and uncluttered, yet function just as I wanted them to. A big thanks to the Devs!
Support reply was quick! Excellent explanation. And the pluging is working perfectly. I would really appreciate if you guys provide some instructions for AND, OR, NOR, NAND etc logic for dumbs like me.
Assim como o Contact Form é essencial para o contato do site, este plugin se faz necessário de acordo com a sua demanda de formas de Contatos com os seus usuários!
I had a form where the number of participants to an event varies. I succesfully used this plugin to make CF7 fields appear conditionally. Everything worked as expected. Thanks Jules.
Contributors & Developers
“Conditional Fields for Contact Form 7” is open source software. The following people have contributed to this plugin.Contributors
Interested in development?
- Fixed bug in 1.3 that broke everything
- Fixed small bug with integration with Contact Form 7 Multi-Step Forms
- Also trigger hiding/showing of groups while typing or pasting text in input fields
- Added support for input type=”reset”
- Added animations
- Added settings page to wp-admin: Contact > Conditional Fields
- Make plugin compatible with CF7 Multi Step by NinjaTeam https://wordpress.org/plugins/cf7-multi-step/
- Improve compatibility with Signature Addon some more.
- Fix critical bug that was present in version 1.2 and 1.2.1
- Improve compatibility with Contact Form 7 Signature Addon: now allowing multiple hidden signature fields.
- Made compatible with Contact Form 7 Multi-Step Forms
- Small bug fix by Manual from advantia.net: now only considering fields which are strictly inside hidden group tags with form submit. Important in some edge cases where form elements get hidden by other mechanisms, i.e. tabbed forms.
- Started work on CF7CF Pro, made some structural code modifications so the free plugin can function as the base for both plugins.
- Removed some debug code
- Updated readme file
- Added import feature
- Added support for nested groups in email
- Tested on WP version 4.7.2 with Contact Form 7 version 4.6.1
- I feel that at this point the plugin is stable enough in most cases, so it’s about time to take it out of beta 🙂
- Update JS en CSS version numbers
- Fix PHP warning with forms that are not using conditional fields (https://wordpress.org/support/topic/conditional-formatting-error/)
- Tested on WP 4.7.1
- Re-added wpcf7_add_shortcode() function if wpcf7_add_form_tag() is not found, because some people claimed to get a “function not found” error for the wpcf7_add_form_tag function with the latest version of CF7 installed. (https://wordpress.org/support/topic/activation-issue-5/ and https://wordpress.org/support/topic/http-500-unable-to-handle-request-error-after-update/)
- Fixed some PHP notices (https://wordpress.org/support/topic/undefined-index-error-in-ajax-response/)
- Attempted to fix error with the CF7 success page redirects plugin (https://wordpress.org/support/topic/warning-invalid-argument-error-for-forms-without-conditional-fields/)
- forgot to update version number in 0.2.7, so changing version to 0.2.8 now.
- Added support for conditional fields in the email (2) field
- Got rid of some PHP warnings
- Saving a form only once, directly after adding or removing conditions, caused conditional logic not to work. This is fixed now. Thanks to @cpaprotna for pointing me in the right direction. (https://wordpress.org/support/topic/no-more-than-3-conditional-statements/)
- Fix validation error with hidden checkbox groups (https://wordpress.org/support/topic/hidden-group-required-field-is-showing-error/)
- Fixed problems with exclusive checkboxes in IE (https://wordpress.org/support/topic/internet-explorer-conditional-exclusive-checkboxes/)
- Changed deprecated function wpcf7_add_shortcode to wpcf7_add_form_tag as it was causing errors in debug mode. (https://wordpress.org/support/topic/wpcf7_add_shortcode-deprecated-notice-2/)
- Removed the hide option and fixed the not-equals option for single checkboxes
- Fixed bug that destroyed the conditional fields in email functionality
- Added support for conditional fields in the other email fields (subject, sender, recipient, additional_headers). Thanks @stevish!
- WP 4.7 broke the required conditional fields inside hidden groups, implemented in version 0.2. Thanks again to @stevish for pointing this out.
- Got rid of checking which groups are hidden both on the front-end (JS) and in the back-end (PHP). Now this is only done in the front-end.
- Tested the plugin with WP 4.7
- Prevent strict standards notice to appear while adding new group via the “Conditional Fields Group” popup.
- Only load cf7cf admin styles and scripts on cf7 pages.
- groups are now reset to their initial states after the form is successfully submitted.
- Bug fix: arrow kept spinning after submitting a form without conditional fields. (https://wordpress.org/support/topic/version-0-2-gives-a-continues-spinning-arrow-after-submitting/)
- Removed anonymous functions from code, so the plugin also works for PHP versions older than 5.3.
- Suppress errors generated if user uses invalid HTML markup in their form code. These errors could prevent form success message from appearing.
- Added support for required conditional fields inside hidden groups. A big thank you to @stevish for implementing this.
- Added support for conditional fields in the email messages. This one also goes entirely to @stevish. Thanks man!
- Added @stevish as a contributer to the project 🙂
- Fix form not working in widgets or other places outside of the loop. Thanks to @ciprianolaru for the solution (https://wordpress.org/support/topic/problem-with-unit_tag-when-not-in-the-loop-form-not-used-in-post-or-page/#post-8299801)
- Fix popup warning to leave page even tough no changes have been made. Thanks to @hhmaster2045 for reporting the bug. https://wordpress.org/support/topic/popup-warning-to-leave-page-even-though-no-changes-have-been-made
- Added export option for easier troubleshooting.
- made compatible with wpcf7-form-control-signature-wrap plugin https://wordpress.org/support/topic/signature-add-on-not-working
- fixed PHP notice thanks to @natalia_c https://wordpress.org/support/topic/php-notice-80
- tested with WP 4.5.3
- Prevent conflicts between different forms on one page.
- Prevent conflicts between multiple instances of the same form on one page. (https://wordpress.org/support/topic/bug-153)
- Changed regex to convert [group] tags to <div> tags, as it was posing some conflicts with other plugins (https://wordpress.org/support/topic/plugin-influence-cf7-send-button-style)
- Removed fielset, id and class attributes for group tags, because they weren’t used anyway and broke the shortcode
- If extra attributes are added to the group shortcode, this will no longer break functionality (even though no attributes are supported)
- Make code work with select element that allows multiple options.
Fixed bug with exclusive checkboxes (https://wordpress.org/support/topic/groups-not-showing)