Title: Nested OR operator
Last modified: July 5, 2023

---

# Nested OR operator

 *  Resolved [gestad2019](https://wordpress.org/support/users/gestad2019/)
 * (@gestad2019)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/nested-or-operator/)
 * Is there a way to have ‘OR’ operator inside a condition like
 * show [prix9] if [compagnie] equals “Air France Tahiti” or ‘Air Antilles”
   and 
   if [fonction] equals “Hôtesse-Steward / Cabin Crew”

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Jules Colle](https://wordpress.org/support/users/jules-colle/)
 * (@jules-colle)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/nested-or-operator/#post-16872753)
 * No, but this will have the same effect:
 *     ```wp-block-code
       show [prix9] if [compagnie] equals "Air France Tahiti"
           and if [fonction] equals "Hôtesse-Steward / Cabin Crew"
       show [prix9] if [compagnie] equals "Air Antilles"
           and if [fonction] equals "Hôtesse-Steward / Cabin Crew"
       ```
   
 * If AND is not used, OR is implied.
 * I see that in your case this leads to some redundancy. One way you could solve
   this to use nested groups:
 *     ```wp-block-code
       [group fonction-cabin-group]
         [group prix9][/group]
       [/group]
       ```
   
 * This way you can Just write this:
 *     ```wp-block-code
       show [prix9] if [compagnie] equals "Air France Tahiti" 
       show [prix9] if [compagnie] equals "Air Antilles"
       show [fonction-cabin-group] if [fonction] equals "Hôtesse-Steward / Cabin Crew"
       ```
   
 *  Thread Starter [gestad2019](https://wordpress.org/support/users/gestad2019/)
 * (@gestad2019)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/nested-or-operator/#post-16874021)
 * ok, so it’s not possible. This was just one part of my code and in my form I 
   need to use many conditions and as pointed I want to avoid redundancy. I dealt
   by repeating each options and thanks to the text editor I could may that quickly.
   What would be a great enhancement would be the ability to create such a logic:
   `
   if condition 1 equals "a" or "b" and condition 2 equals "1" or "2" then field-
   x is shown`Could you add this to your plugin? I’m used to the extraordinary webform
   on Drupal and I dream of such power in Contact form7 🙂
 *  Plugin Author [Jules Colle](https://wordpress.org/support/users/jules-colle/)
 * (@jules-colle)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/nested-or-operator/#post-16874152)
 * Can you set up a small version of your form so I can understand the logic better?
   You can set up the form via [https://conditional-fields-cf7.bdwm.be/form-tester/](https://conditional-fields-cf7.bdwm.be/form-tester/)
 * The cases in which it’s necessary to use AND in combination with a group of OR
   conditions are very rare. Most of the times it can be solved by rearranging your
   groups a bit. I want to understand your case so I can justify spending the extra
   development time to create more complexity. I want to make 100% sure that it’s
   necessary and there are no elegant solutions possible without it. I greatly appreciate
   your help.
 *  Thread Starter [gestad2019](https://wordpress.org/support/users/gestad2019/)
 * (@gestad2019)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/nested-or-operator/#post-16874186)
 * here is a copy of my form: [http://conditional-fields-cf7.bdwm.be/form-tester/?hash=1359cada87fd46e42737d3945f40bdf2](http://conditional-fields-cf7.bdwm.be/form-tester/?hash=1359cada87fd46e42737d3945f40bdf2)
   
   for example, you’ll see that I had to repeat all last lines instead of just writing
   something like:`show [prix9] if [compagnie] equals "La Compagnie || Lux Aviation
   || Norse || ..."` using the php syntax for ORI’m looking forward reading your
   alternative but I’m used to conditional logic and couldn’t figure out how to 
   make it easier.(btw, it’s a cool tool to test a form)
 *  Plugin Author [Jules Colle](https://wordpress.org/support/users/jules-colle/)
 * (@jules-colle)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/nested-or-operator/#post-16920912)
 * Sorry for the late reply. You might find this useful: [https://conditional-fields-cf7.bdwm.be/advanced-conditional-logic-with-custom-javascript-functions/](https://conditional-fields-cf7.bdwm.be/advanced-conditional-logic-with-custom-javascript-functions/)
 * This option is only available in the Pro version though.
 *  Thread Starter [gestad2019](https://wordpress.org/support/users/gestad2019/)
 * (@gestad2019)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/nested-or-operator/#post-16958364)
 * Hi Jules, thanks for your answer. I was aware i could add custom JS with the 
   pro version. I would be a better option (even a paid one) to deal with conditions
   on the front end as not everybody is about to use JS (and also access to functions.
   php file).
 *  Plugin Author [Jules Colle](https://wordpress.org/support/users/jules-colle/)
 * (@jules-colle)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/nested-or-operator/#post-16958561)
 * I’ll think about it. But you don’t need access to functions.php. You can add 
   the JavaScript code straight in your form between script tags.
 *  Thread Starter [gestad2019](https://wordpress.org/support/users/gestad2019/)
 * (@gestad2019)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/nested-or-operator/#post-16958661)
 * You’re right. Anyway, I wish you could add it a front-end setting. Would you 
   need some funding for that?

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Nested OR operator’ is closed to new replies.

 * ![](https://ps.w.org/cf7-conditional-fields/assets/icon-256x256.png?rev=2072595)
 * [Conditional Fields for Contact Form 7](https://wordpress.org/plugins/cf7-conditional-fields/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cf7-conditional-fields/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cf7-conditional-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/cf7-conditional-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cf7-conditional-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cf7-conditional-fields/reviews/)

## Tags

 * [operator](https://wordpress.org/support/topic-tag/operator/)

 * 8 replies
 * 2 participants
 * Last reply from: [gestad2019](https://wordpress.org/support/users/gestad2019/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/nested-or-operator/#post-16958661)
 * Status: resolved