Skip to content

Instantly share code, notes, and snippets.

@matthiaspabst
Created October 24, 2019 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthiaspabst/d6da01ab6755fdce06201f60c9eda9ac to your computer and use it in GitHub Desktop.
Save matthiaspabst/d6da01ab6755fdce06201f60c9eda9ac to your computer and use it in GitHub Desktop.
Gravity Forms Antispam
<?php
/**
* Gravity Forms Antispam
* Check if field has a predefined value
* https://docs.gravityforms.com/gform_field_validation/#1-number-field-validation
*/
function gf_antispam( $result, $value, $form, $field ) {
if ( $result['is_valid'] && intval( $value ) !== 9 ) {
$result['is_valid'] = false;
$result['message'] = 'Please enter correct value';
}
return $result;
}
// Form ID 2 , Field ID 8
add_filter( 'gform_field_validation_2_8', 'gf_antispam', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment