Skip to content

Instantly share code, notes, and snippets.

@solepixel
Last active February 25, 2020 04:19
Show Gist options
  • Save solepixel/c8ab2ff61ed55bffa52b5b2a21663c0f to your computer and use it in GitHub Desktop.
Save solepixel/c8ab2ff61ed55bffa52b5b2a21663c0f to your computer and use it in GitHub Desktop.
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