Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Created June 20, 2019 17:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackkatz/80f0327f17ecce8691cafbd61b1978de to your computer and use it in GitHub Desktop.
Save zackkatz/80f0327f17ecce8691cafbd61b1978de to your computer and use it in GitHub Desktop.
Only allow integers (whole numbers, including negative values) in Gravity Forms Number field
<?php
/**
* Force number fields to increment by 1
*/
add_filter( 'gform_field_content', function ( $field_content, $field ) {
if ( 'number' !== $field->type ) {
return $field_content;
}
return str_replace( "step='any'", "step='1'", $field_content );
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment