Descripción
Este plugin añade lógica condicional a 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 have added the field group(s), go to the «Conditional fields» tab to create one or more conditions that will make the group(s) appear.
Conditional Fields for Contact Form 7 is an independent plugin. This plugin is not affiliated with or endorsed by the developers of Contact Form 7.
Cómo se usa
Características principales
Compatibilidad para los campos obligatorios
Required fields inside hidden groups will never trigger validation errors.
Ocultar o mostrar información en los correos electrónicos con base en qué grupos son visibles
Los grupos condicionales ahora también pueden añadirse a los correos electrónicos.
Solo hay que envolver el contenido con las etiquetas [group-name] ... [/group-name]
.
Los grupos pueden anidarse
Los grupos pueden anidarse, tanto en el formulario como en el correo electrónico
Ejemplo de formulario:
[group group-1]
[group group-inside-1]
...
[/group]
[/group]
Ejemplo de correo electrónico:
[group-1]
[group-inside-1]
...
[/group-inside-1]
[/group-1]
Avanzado
Los usuarios avanzados pueden codificar las condiciones como texto sin formato en lugar de usar las casillas de selección, usando la vista de texto.
¿Necesitas más potencia?
Al igual que WordPress, la potencia de Contact Form 7 reside en su rico ecosistema de extensiones que se construyen sobre él. Sin embargo, puede ser difícil encontrar un conjunto de extensiones complejas que funcionen bien juntas.
Por eso he creado Conditional Fields Pro. Este añade algunas potentes características a Contact Form 7 y garantiza que todo funcionará sin problemas con Conditional Fields.
Las características Pro incluyen:
- Campos repetibles (repetidores)
- Formularios de múltiples pasos (multipasos)
- Condiciones personalizadas con funciones de JavaScript
- Conditions with regular expressions
- Multiple file upload
Get the PRO version of Conditional Fields for Contact Form 7!
Capturas
Instalación
Por favor, sigue el procedimiento de instalación estándar para los plugins de WordPress.
Sigue este tutorial si no estás seguro de cómo usar el plugin.
FAQ
-
El mensaje de correo electrónico no muestra los valores correctos o se envían valores incorrectos
-
Todos los nombres de campo deben ser únicos
Aunque tus campos nunca aparezcan al mismo tiempo, es importante saber que WPCF7CF no eliminará los campos, simplemente los oculta. Así que, todos los campos serán enviados cuando se envíe el formulario. Debido a esto, dos campos no pueden tener el mismo nombre.
Formulario incorrecto (2 elementos de entrada con el mismo nombre «a»):
[group group-1][select a "1" "2" "3"][/group] [group group-2][select a "1" "2" "3"][/group]
Formulario correcto (todos los grupos y campos tienen nombres únicos):
[group group-1][select a "1" "2" "3"][/group] [group group-2][select b "1" "2" "3"][/group]
-
Razón #1: Error de JavaScript
Revisa la consola de tu navegador (F12) para ver si hay algún error de JavaScript. WPCF7CF carga sus scripts en la parte inferior de la página HTML, así que si algún error de JavaScript se produce antes de eso, el código no se ejecutará en la mayoría de los navegadores.
Antes de contactar en el foro de soporte, intenta determinar qué plugin o tema está causando el problema, desactivando gradualmente los plugins y cambiando el tema.Razón #2: wp_footer() no está cargado
Comprueba si tu tema está llamando a la funciónwp_footer()
. Normalmente, esta función se llamará en el archivo footer.php de tu tema.
El código JavaScript de los campos condicionales se carga en wp_footer, por lo que una llamada a esta función es crucial. Si no hay tal llamada en tu tema, ve al archivo footer.php de tu tema y añade este código justo antes de la etiqueta de cierre</body>
:
<?php wp_footer(); ?>
Reseñas
Colaboradores y desarrolladores
«Conditional Fields for Contact Form 7» es un software de código abierto. Las siguientes personas han colaborado con este plugin.
Colaboradores«Conditional Fields for Contact Form 7» está traducido en 14 idiomas. Gracias a los traductores por sus contribuciones.
Traduce «Conditional Fields for Contact Form 7» a tu idioma.
¿Interesado en el desarrollo?
Revisa el código , echa un vistazo al repositorio SVN o suscríbete al registro de desarrollo por RSS.
Registro de cambios
2.5.7 (2025-01-14)
- Fully tested with Contact Form 7 version 6.0.3
2.5.6 (2024-12-23)
- Fully tested with Contact Form 7 version 6.0.2
2.5.5 (2024-12-20)
- FREE: Rename plugin folder and main file from contact-form-7-conditional-fields/contact-form-7-conditional-fields to conditional-fields
- PRO: Rename plugin folder and main file from contact-form-7-conditional-fields-pro to conditional-fields-pro/conditional-fields.php
2.5.4 (2024-12-05)
- Remove some code in the free plugin that was only needed for the PRO version.
2.5.3 (2024-12-04)
- Fix form-tag generator button. Now you can insert [group] tags again with the new CF7 form-tag generator. Renamed the button to «Conditional group».
2.5.2 (2024-11-27)
- Fully tested with Contact Form 7 version 6.0.1
- Tested up to WP 6.7
2.5.1 (2024-11-03)
- Temporarily remove Conditional Fields buttons to prevent conflicts with CF7 6.0. This means you need to enter the [group] tags manually and can’t insert them with the form-tag generator buttons anymore. We are looking into a fix.
- Fully tested with Contact Form 7 version 6.0
2.5 (2024-10-22)
- Add Plugin Dependency for CF7 in plugin header
- fix deprecated warning dynamic property creation
- fix Using ${var} in strings is deprecated
- Fix XSS vulnerability in admin settings page. Thanks to Patchstack for reporting this issue.
- PRO: Fix: [response] tag doesn’t work properly in multistep #127
- PRO: Add support for checkbox free_text option in summary field #126
- PRO: Fix: [multifile] allows uploading of filetype that is not specified in allowed filetypes [#103]((https://github.com/pwkip/contact-form-7-conditional-fields/issues/103)
2.4.15 (2024-07-27)
- Fully tested with Contact Form 7 version 5.9.8
2.4.14 (2024-07-18)
- Fix medium security problem (CVSS 4.3). Thanks to Wordfence for reporting this issue.
- Fully tested with Contact Form 7 version 5.9.7
- Tested up to WP 6.6
2.4.13 (2024-06-29)
- Fully tested with Contact Form 7 version 5.9.6
2.4.12 (2024-05-25)
- Fully tested with Contact Form 7 version 5.9.5
2.4.11 (2024-05-12)
- PRO: multistep – Disable next button and prevent submitting while step is being validated.
- Fully tested with Contact Form 7 version 5.9.4
2.4.10 (2024-03-30)
- Fix crappy release
2.4.9 (2024-03-30)
- Fully tested with Contact Form 7 version 5.9.3
2.4.8 (2024-03-14)
- Fully tested with Contact Form 7 version 5.9.2
2.4.7 (2024-02-13)
- Fully tested with Contact Form 7 version 5.8.7
2.4.6 (2024-01-15)
- Fully tested with Contact Form 7 version 5.8.6
2.4.5 (2023-12-19)
- Fix bug with Multistep validation. Caused by cf7cf script not depending on cf7 script.
- Fully tested with Contact Form 7 version 5.8.5
2.4.4 (2023-12-10)
- Fully tested with Contact Form 7 version 5.8.4
2.4.3 (2023-11-23)
- Tested up to WP 6.4
2.4.2 (2023-11-22)
- Prevent «CF7 needs to be installed» notice from being dismissable. (This notice is only shown to users with the update_plugins capability)
- Add nonce for dismissing other notices, so bad people who are stealing your session can’t dismiss your precious CF7CF related notices on your behalf anymore. Hopefully now the people of Patchstack will be happy and stop marking this plugin as vulnerable.
- Tested up to WP 6.3
- Remove some unused constants
2.4.1 (2023-11-16)
- Patch minor access-control vulnerability reported by patchstack
- Fully tested with Contact Form 7 version 5.8.3
2.4 (2023-11-13)
- Removed webpack build. (This might cause JS errors in outdated browsers.)
- Fix admin validator Error. Thanks to joostdekeijzer
- Fix some jQuery code. Thanks to hirasso
2.3.12 (2023-10-27)
- Fully tested with Contact Form 7 version 5.8.2
2.3.11 (2023-10-03)
- Fully tested with Contact Form 7 version 5.8.1
2.3.10 (2023-08-07)
- Fully tested with Contact Form 7 version 5.8
2.3.9 (2023-05-31)
- Fully tested with Contact Form 7 version 5.7.7
2.3.8 (2023-04-23)
- Fully tested with Contact Form 7 version 5.7.6
2.3.7 (2023-04-13)
- PRO: Fix obscure bug with disable_on_hide. Disabled fields didn’t get recognized after calling reset() on the form element or after adding a repeater, causing conditions relying on disabled fields to malfunction.
2.3.6 (2023-04-11)
- Fully tested with WP version 6.2
2.3.5 (2023-03-24)
- Fully tested with Contact Form 7 version 5.7.5.1
- Note: Previously it was possible to add a contact-form shortcode with only the title and not the ID. But since the last update of CF7 this seems to throw an error. Use the official shortcode provided by CF7 to prevent this.
2.3.4 (2023-02-19)
- Fully tested with Contact Form 7 version 5.7.4
2.3.3 (2023-01-26)
- PRO: Fix [summary]. CF7 5.7.3 introduced a tag-check function which [summary] did not pass.
- Fully tested with Contact Form 7 version 5.7.3
2.3.2 (2022-12-28)
- Fully tested with Contact Form 7 version 5.7.2
2.3.1 (2022-12-17)
- PRO: fix problem with line breaks in multistep forms.
2.3 (2022-12-16)
- Fully tested with Contact Form 7 version 5.7.1
- PRO: Changed containing element for repeater and step controls from DIV to P. Otherwise CF7 would create additional P elements.
2.2.11 (2022-12-13)
- DO NOT UPDATE TO CONTACT FORM VERSION 5.7!! At least wait for version 5.7.1 before updating
- Reverted autop-fix because it was causing addional errors.
- Reverted compatibility declaration to CF7 version 5.6.4
2.2.10 (2022-12-11)
- Fully tested with Contact Form 7 version 5.7 (when WP_DEBUG is false). Note: due to some errors in Contact Form 7 version 5.7 you will need to make sure WP_DEBUG is set to false in your wp-config.php file.
- disable automatic insertion of paragraphs. Recent CF7 updates have changed the autop mechanism, causing too many problems with parsing the HTML code. If you still want to use autop (at your own risk) copy this code to your functions.php file:
add_filter( 'wpcf7_autop_or_not', '__return_true', 41, 0);
. Untill further notice Conditional Fields and Conditional Fields for Contact Form 7 will not use the automatic paragraph feature of CF7. Always try to write clean and valid HTML code. GH issue 85
2.2.9 (2022-10-19)
- Fully tested with Contact Form 7 version 5.6.4
- Add action hook: wpcf7cf_step_completed
2.2.8 (2022-10-14)
- Fix acceptance field bug
2.2.7 (2022-10-14)
- Remove unwanted whitespace between closing and opening group tags in mail messages.
- Fix problems with acceptance fields More info
- Redesign of form tester
2.2.6 (2022-09-08)
- PRO: Fix issues with validation in nested repeaters GH issue 92
- Fix error with optional file field in hidden group GH issue 92
2.2.5 (2022-09-04)
- PRO: Fix bug with togglebutton
2.2.4 (2022-09-01)
- Fully tested with Contact Form 7 version 5.6.3
- JS code refactoring
- Allow adding class names to group. For example: [group g class:my-class][/group]
2.2.3 (2022-08-10)
- Fully tested with Contact Form 7 version 5.6.2
- Fix for smartgrid plugin
- Some code refactoring
2.2.2 (2022-08-07)
- Mejoras de rendimiento
2.2.1 (2022-07-21)
- Fully tested with Contact Form 7 version 5.6.1
2.2 (2022-06-17)
- Make compatibile with Contact Form 7 version 5.6
2.1.6 (2022-06-07)
- Fix bug: text view cleared after making a change to form code when there are more than 50 conditions.
2.1.5 (2022-05-22)
- Fully tested with Contact Form 7 version 5.5.6.1
2.1.4 (2022-05-16)
- It’s no longer needed to save the form before adding conditions. Available groups are updated instantaneously after adding/changing them in the form editor.
- Fix problems when group is named «children» GH issue 74
- Fix problems with unsaved changes notice GH issue 91
- Tested up to WP 6.0
2.1.3 (2022-04-18)
- check for user_cap ‘wpcf7_edit_contact_forms’ instead of ‘wpcf7_edit_contact_form’ in several places. Thanks, @paybox!
- PRO multistep: make «Next step» and «Previous step» buttons translatable by third party plugins like wpml and loco translate.
- PRO multistep: show spinner while validating a step.
- PRO Fix additional disable_on_hide bug with multistep GH issue 87-4
- Replace all occurences of text domain ‘contact-form-7’ with ‘cf7-conditional-fields’
2.1.2 (2022-02-23)
- Fully tested with Contact Form 7 version 5.5.6
2.1.1 (2022-02-14)
- Fully tested with Contact Form 7 version 5.5.5
- Make scroll to success message less annoying. GH Issue 90
- Add extra check to make sure that scroll to success message only happens when the e-mail is sent. GH Issue 90
- PRO: fix disable_on_hide bugs. GH sssue 87
2.1 (2022-01-27)
- Tested up to wp 5.9
- Scroll success message into view after successful form submission. GH Issue 90
- Small changes GH PR 86
- Make ‘change’ event bubble up GH PR 88
2.0.9 (2022-01-20)
- Fully tested with Contact Form 7 version 5.5.4
2.0.8 (2021-11-28)
- Check how code changes in CF7 related to
wpcf7_contact_form_properties
impact the plugin, and update TODO comments accordingly. - Fully tested with Contact Form 7 version 5.5.3
- Write additional tests for forms loaded via AJAX
- only show compatibility notices to users with the update_plugins capabilities
2.0.7 (2021-10-26)
- Fully tested with Contact Form 7 version 5.5.2 (and also make the warning message disappear if all plugins are up to date)
2.0.6 (2021-10-26)
- Fully tested with Contact Form 7 version 5.5.2
2.0.5 (2021-10-13)
- Fully tested with Contact Form 7 version 5.5.1
2.0.4 (2021-07-19)
- Fix issue with required file fields
- Fully tested with Contact Form 7 version 5.4.2
2.0.3 (2021-05-02)
- Fully tested with Contact Form 7 version 5.4.1
- (dev note: fixed automated tests)
2.0.2 (2021-04-06)
- Fix bug: third-party required fields not triggering validation. Thanks @dedotombo!
2.0.1 (2021-03-31)
- Force height:auto on groups. (Fixes regression errors with groups inside repeaters)
- Allow more funky characters as conditional fields values (there was a problem with less than sign <)
- Fix bug with hidden required file and multifile fields causing validation errors
- Implemented extra tests so these errors cannot reoccur in future updates.
2.0 (2021-03-29)
- WARNING! 2.0 requires at least Contact Form 7 version 5.4 to work!
- Make plugin compatible with CF7 5.4
- Modify wpcf7cf_generate_summary function, so it can be used without $_POST
- fix animaton when showing group