Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fixes Gravity Forms Custom Validation Message
<?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