• Resolved pbre

    (@pbre)


    Hey,
    for excluding several things like

    hide if IBAN "not contains" DE

    It would be awesome to have this feature

    from um-filters-fields.php and “Validate conditional logic” section I’ve tried to adapt the contains condition to match the not contains condition

    if ( isset( $_POST[ $condition_metakey ] ) ) {
    				$cond_value = ( $fields[ $value[1] ]['type'] === 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ];
    				list( $visibility, $parent_key, $op, $parent_value ) = $value;
    
    				if ( $visibility == 'hide' ) {
    					if ( $op == 'empty' ) {
    						if ( empty( $cond_value ) ) {
    							$array['required'] = 0;
    						}
    					} elseif ( $op == 'not empty' ) {
    						if ( ! empty( $cond_value ) ) {
    							$array['required'] = 0;
    						}
    					} elseif ( $op == 'equals to' ) {
    						if ( $cond_value == $parent_value ) {
    							$array['required'] = 0;
    						}
    					} elseif ( $op == 'not equals' ) {
    						if ( $cond_value != $parent_value ) {
    							$array['required'] = 0;
    						}
    					} elseif ( $op == 'greater than' ) {
    						if ( $cond_value > $parent_value ) {
    							$array['required'] = 0;
    						}
    					} elseif ( $op == 'less than' ) {
    						if ( $cond_value < $parent_value ) {
    							$array['required'] = 0;
    						}
    					} elseif ( $op == 'contains' ) {
    						if ( is_string( $cond_value ) && strstr( $cond_value, $parent_value ) ) {
    							$array['required'] = 0;
    						}
    						if( is_array( $cond_value ) && in_array( $parent_value, $cond_value ) ) {
    							$array['required'] = 0;
    						}
    					}
    					// Add a new condition for "not contains"
    					elseif ( $op == 'not contains' ) {
    						if ( is_string( $cond_value ) && ! strstr( $cond_value, $parent_value ) ) {
    							$array['required'] = 0;
    						}
    						if( is_array( $cond_value ) && ! in_array( $parent_value, $cond_value ) ) {
    							$array['required'] = 0;
    						}
    					}
    				} elseif ( $visibility == 'show' ) {
    					if ( $op == 'empty' ) {
    						if ( ! empty( $cond_value ) ) {
    							$array['required'] = 0;
    						}
    					} elseif ( $op == 'not empty' ) {
    						if ( empty( $cond_value ) ) {
    							$array['required'] = 0;
    						}
    					} elseif ( $op == 'equals to' ) {
    						if ( $cond_value != $parent_value ) {
    							$array['required'] = 0;
    						}
    					} elseif ( $op == 'not equals' ) {
    						if ( $cond_value == $parent_value ) {
    							$array['required'] = 0;
    						}
    					} elseif ( $op == 'greater than' ) {
    						if ( $cond_value <= $parent_value ) {
    							$array['required'] = 0;
    						}
    					} elseif ( $op == 'less than' ) {
    						if ( $cond_value >= $parent_value ) {
    							$array['required'] = 0;
    						}
    					} elseif ( $op == 'contains' ) {
    						if( is_string( $cond_value ) && !strstr( $cond_value, $parent_value ) ) {
    							$array['required'] = 0;
    						}
    						if( is_array( $cond_value ) && !in_array( $parent_value, $cond_value ) ) {
    							$array['required'] = 0;
    						}
    					}
    					// Add a new condition for "not contains"
    					elseif ( $op == 'not contains' ) {
    						if( is_string( $cond_value ) && strstr( $cond_value, $parent_value ) ) {
    							$array['required'] = 0;
    						}
    						if( is_array( $cond_value ) && in_array( $parent_value, $cond_value ) ) {
    							$array['required'] = 0;
    						}
    					}
    				}
    			}
Viewing 1 replies (of 1 total)
  • Plugin Support andrewshu

    (@andrewshu)

    Hello @pbre

    Unfortunately, this functionality does not exist in our plugin at this time. Maybe we will add this in 3 version of the UM.

    Thank you

    • This reply was modified 2 years, 11 months ago by andrewshu.
    • This reply was modified 2 years, 11 months ago by andrewshu.
Viewing 1 replies (of 1 total)

The topic ‘Add “not contains” logic for conditional fields support’ is closed to new replies.