Title: Conditional User Field Logic &#8211; Adding multiple conditions
Last modified: March 22, 2023

---

# Conditional User Field Logic – Adding multiple conditions

 *  Resolved [Salih K](https://wordpress.org/support/users/salihkulangara/)
 * (@salihkulangara)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/conditional-user-field-logic-adding-multiple-conditions/)
 * I would like to add multiple conditions for custom fields, and I have been trying
   this [documentation](https://www.paidmembershipspro.com/documentation/user-fields/field-types-attributes/#conditional).
   I mean I need to show a **fieldXX** whether user selects **field 1** or **filed
   2**. Doc says “The depends array should contain an array of conditions formatted
   like `array(array('id' => {field_name}, 'value' => {field_value}))`“, it works
   for single condition but not for multiple conditions.
 * When you say “array of conditions” could you help how do we add multiple conditions?

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

 *  Plugin Support [Kim White](https://wordpress.org/support/users/kimwhite/)
 * (@kimwhite)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/conditional-user-field-logic-adding-multiple-conditions/#post-16592999)
 * Hello [@salihkulangara](https://wordpress.org/support/users/salihkulangara/) ,
 * This post here should be able to give you more information on doing this: [https://www.paidmembershipspro.com/conditional-user-field-member-profile-checkout/](https://www.paidmembershipspro.com/conditional-user-field-member-profile-checkout/)
 * You may have to have a depend array in an array EXAMPLE…
 *     ```wp-block-code
       'depends' => array(
           array(
               'id' => 'how_hear',
               'value' => 'Other'
           ),
           array(
               'id' => 'how_hear2',
               'value' => 'Other2'
           ),
       ) 
       ```
   
 * Please let me know if this information is what you are looking for.
 * KIm W
 *  Thread Starter [Salih K](https://wordpress.org/support/users/salihkulangara/)
 * (@salihkulangara)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/conditional-user-field-logic-adding-multiple-conditions/#post-16595155)
 * [@kimwhite](https://wordpress.org/support/users/kimwhite/) Thank you so much.
 * To make my scenario more clearer, let me give you an example:
 * In a form I have radio buttons to select ‘Single’ and ‘Couple'(_field labelled
   as Status_), If ‘single’ is selected ‘First Name’ and ‘Last Name’ will be shown,
   and if ‘Couple’ is selected need to show ‘First Name’, ‘Last Name’, ‘Spouse First
   Name’ and ‘Spouse Last Name'(here First Name and Last Name is common to both 
   status)
 * In this scenario how can I give condition to First Name and Last Name. If I use
   below like code it wont work. It check both conditions for true, right? In another
   words I think not AND but need OR condition.
 * ‘depends’ => array( array( ‘id’ => ‘status’, ‘value’ => ‘Single’ ), array( ‘id’
   => ‘Status’, ‘value’ => ‘Couple’ ), )
 * **Also one related question**, Is there a way that we can make a radio button
   selected by default when field is created through User fields section?
 *  Plugin Support [Kim White](https://wordpress.org/support/users/kimwhite/)
 * (@kimwhite)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/conditional-user-field-logic-adding-multiple-conditions/#post-16599865)
 * Hello,
 * I don’t know if this is possible with the User Fields GUI. You may be able to
   access these fields with a custom code like this: I use a checkbox to show the
   additional spouse fields.
 * [https://gist.github.com/kimwhite/9d5e6b2afbe0e5dc24c0d7ad091ef93b](https://gist.github.com/kimwhite/9d5e6b2afbe0e5dc24c0d7ad091ef93b)
 * Kim W
 *  [danooh](https://wordpress.org/support/users/danooh/)
 * (@danooh)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/conditional-user-field-logic-adding-multiple-conditions/#post-16632129)
 * Hey [@salihkulangara](https://wordpress.org/support/users/salihkulangara/) ,
 * you need to pass an array for the value to be checked. Try the following:
 *     ```wp-block-code
       'depends' => array(
       array('id' => 'status', 'value' => array('Single', 'Couple')) )
       ```
   
 * I faced a similar problem and fixed it using the above mentioned way to achieve
   an OR-logic with regards the dependancy.
   Please let me know if this fixed it 
   for you as well!Best regardsDaniel
 *  Thread Starter [Salih K](https://wordpress.org/support/users/salihkulangara/)
 * (@salihkulangara)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/conditional-user-field-logic-adding-multiple-conditions/#post-16632390)
 * Hi [@danooh](https://wordpress.org/support/users/danooh/) thank you for the tip,
   but unfortunately that does not work for me. I have even tried your tip in [Kims code](https://gist.github.com/kimwhite/9d5e6b2afbe0e5dc24c0d7ad091ef93b).
   No luck. FYI, I am using the latest version of PMPRO, and not using Register 
   Helper Addon.
 *  [danooh](https://wordpress.org/support/users/danooh/)
 * (@danooh)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/conditional-user-field-logic-adding-multiple-conditions/#post-16632474)
 * Hi [@salihkulangara](https://wordpress.org/support/users/salihkulangara/) 
   I 
   am also using the latest version of PMPRO. Can you provide a snippet of your 
   implementation? Like the whole function that you put into the “pmpro-customizations.
   php”On my site I am verifying against multiple conditions (if user picks x or
   y or z out 10 possible options, then to display a specific custom user field)
   and it does work.
    -  This reply was modified 3 years, 2 months ago by [danooh](https://wordpress.org/support/users/danooh/).
 *  [danooh](https://wordpress.org/support/users/danooh/)
 * (@danooh)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/conditional-user-field-logic-adding-multiple-conditions/#post-16632715)
 * Update [@salihkulangara](https://wordpress.org/support/users/salihkulangara/)
   
   You may try my solution by changing the type of field ‘Status’ to select.
 * I will look into multiple conditions on radio fields:
   **Edit:**I checked the 
   class-pmpro-field.php. There is a flag implemented to determine whether conditions
   should be AND’ed or OR’ed (by default ‘depends_or’ is set to false)
 * 
   Put it like this, adjust values to match yours and it will work with field type‘
   radio’
 *     ```wp-block-code
       'depends_or'		=>true,
       'depends'		=> array(
       array('id' => 'status', 'value' => 'single'),
       array('id' => 'status', 'value' => 'couple')
       )
       ```
   
    -  This reply was modified 3 years, 2 months ago by [danooh](https://wordpress.org/support/users/danooh/).
    -  This reply was modified 3 years, 2 months ago by [danooh](https://wordpress.org/support/users/danooh/).
 *  Thread Starter [Salih K](https://wordpress.org/support/users/salihkulangara/)
 * (@salihkulangara)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/conditional-user-field-logic-adding-multiple-conditions/#post-16632848)
 * [@danooh](https://wordpress.org/support/users/danooh/) thank you so much, that
   worked. Do you see any option that we can add to make a radio button selected
   by default(I mean adding the ‘checked’ attribute).
 *  [danooh](https://wordpress.org/support/users/danooh/)
 * (@danooh)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/conditional-user-field-logic-adding-multiple-conditions/#post-16632925)
 * [@salihkulangara](https://wordpress.org/support/users/salihkulangara/) did you
   add your radio button via custom code?
   I did not find ‘checked’-attribute but
   you can try adding ‘value’ to the array and assign the pre-checked value when
   creating the user field:
 *     ```wp-block-code
       $fields[] = new PMPro_Field(
       'status',
       'radio',
       array(
        'label' => 'Status',
        'options'=>array('single','couple'),
        'value' => 'couple'
        )
       );
       ```
   
 * Btw.: I did not test submitting the form.
 *  Thread Starter [Salih K](https://wordpress.org/support/users/salihkulangara/)
 * (@salihkulangara)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/conditional-user-field-logic-adding-multiple-conditions/#post-16633681)
 * [@danooh](https://wordpress.org/support/users/danooh/) Yes, I had added fields
   via new user field UI, there is no option for that, So I have to create filed
   via custom code.
 * Thank you so much for your help 🙂
    -  This reply was modified 3 years, 2 months ago by [Salih K](https://wordpress.org/support/users/salihkulangara/).
 *  [Michael Beil](https://wordpress.org/support/users/michaelbeil/)
 * (@michaelbeil)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/conditional-user-field-logic-adding-multiple-conditions/#post-16662394)
 * Because there have not been any recent updates to this topic, we will be changing
   the status to resolved. If you have any new questions or if your issue persists,
   please feel free to create a new topic.

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

The topic ‘Conditional User Field Logic – Adding multiple conditions’ is closed 
to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/paid-memberships-pro_f1dacb.svg)
 * [Paid Memberships Pro - Content Restriction, User Registration, & Paid Subscriptions](https://wordpress.org/plugins/paid-memberships-pro/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/paid-memberships-pro/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/paid-memberships-pro/)
 * [Active Topics](https://wordpress.org/support/plugin/paid-memberships-pro/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/paid-memberships-pro/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/paid-memberships-pro/reviews/)

## Tags

 * [Conditional Fields](https://wordpress.org/support/topic-tag/conditional-fields/)

 * 11 replies
 * 4 participants
 * Last reply from: [Michael Beil](https://wordpress.org/support/users/michaelbeil/)
 * Last activity: [3 years, 1 month ago](https://wordpress.org/support/topic/conditional-user-field-logic-adding-multiple-conditions/#post-16662394)
 * Status: resolved