Last active
February 25, 2020 04:19
-
-
Save solepixel/c8ab2ff61ed55bffa52b5b2a21663c0f to your computer and use it in GitHub Desktop.
Fixes Gravity Forms Custom Validation Message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'gform_field_validation', 'mytheme_fix_custom_validation', 10, 4 ); | |
/** | |
* Fixes Gravity Forms Custom validation message. | |
* | |
* @link https://docs.gravityforms.com/gform_field_validation/ | |
* | |
* @param array $result The result array. | |
* @param string $value The value of the field. | |
* @param array $form The Gravity Form array. | |
* @param object $field The form field object. | |
* | |
* @return array The result array. | |
*/ | |
function mytheme_fix_custom_validation( $result, $value, $form, $field ) { | |
if ( ! $result['is_valid'] && ! empty( $field->errorMessage ) ) { | |
$result['message'] = $field->errorMessage; | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment