Skip to content

Instantly share code, notes, and snippets.

@raelshark
Created August 9, 2019 08:06
Show Gist options
  • Save raelshark/689ec1bbd0d6e80dce47f20d44ff4d41 to your computer and use it in GitHub Desktop.
Save raelshark/689ec1bbd0d6e80dce47f20d44ff4d41 to your computer and use it in GitHub Desktop.
Case-Insensitive Gravity Forms Email Comparison
//Make the Gravity Forms email comparison case-insensitive
add_filter( 'gform_field_validation', function ( $result, $value, $form, $field ) {
if ( ! $result['is_valid'] && $field->get_input_type() === 'email' ) {
$email = is_array( $value ) ? rgar( $value, 0 ) : $value;
if ( $field->emailConfirmEnabled && ! empty( $email ) ) {
$confirm = is_array( $value ) ? rgar( $value, 1 ) : $this->get_input_value_submission( 'input_' . $field->id . '_2' );
if ( strcasecmp($confirm,$email) != 0 ) {
echo 'does not match';
$result['is_valid'] = false;
$result['message'] = esc_html__( 'Your emails do not match.', 'gravityforms' );;
} else {
$result['is_valid'] = true;
$result['message'] = '';
}
}
}
return $result;
}, 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment