Skip to content

Instantly share code, notes, and snippets.

@rafaehlers
Created October 9, 2017 19:02
Show Gist options
  • Save rafaehlers/fd24f3c90dffa3665a3df56c4581df1a to your computer and use it in GitHub Desktop.
Save rafaehlers/fd24f3c90dffa3665a3df56c4581df1a to your computer and use it in GitHub Desktop.
<?php
add_filter( 'gform_is_value_match', function( $is_match, $field_value, $target_value, $operation, $source_field, $rule ) {
/**
* Fix this issue for dates temporarily:
* https://github.com/gravityforms/gravityforms/commit/9d37fee852fe9946f030938bfa231e762f687728#commitcomment-23642339
*/
if ( ! $is_match && is_string( $field_value ) && is_string( $target_value ) ) {
switch ( $operation ):
case '>': return $field_value > $target_value;
case '<': return $field_value < $target_value;
endswitch;
}
return $is_match;
}, 10, 6 );
@soulseekah
Copy link

Stopped working after v2.0.14 GravityKit/GravityView@d09b3bc

@soulseekah
Copy link

soulseekah commented Sep 24, 2018

A fix before we figure out what's wrong. Then back to the original one (in GV 2.1).

<?php
add_filter( 'gform_is_value_match', function( $is_match, $field_value, $target_value, $operation, $source_field, $rule ) {
    if ( is_array( $field_value ) && count( $field_value ) == 1 && ! is_array( $target_value ) ) {
        $field_value = array_pop( $field_value );
    }
    /**
     * Fix this issue for dates temporarily:
     * https://github.com/gravityforms/gravityforms/commit/9d37fee852fe9946f030938bfa231e762f687728#commitcomment-23642339
     */
    if ( ! $is_match && is_string( $field_value ) && is_string( $target_value ) ) {
        switch ( $operation ):
            case '>': return $field_value > $target_value;
            case '<': return $field_value < $target_value;
        endswitch;
    }
    return $is_match;
}, 10, 6 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment