Skip to content

Instantly share code, notes, and snippets.

@matty0501
Last active April 25, 2023 12:30
Show Gist options
  • Save matty0501/a48dd2eaaaa5870c9e934994b30a8f04 to your computer and use it in GitHub Desktop.
Save matty0501/a48dd2eaaaa5870c9e934994b30a8f04 to your computer and use it in GitHub Desktop.
<?php
/**
* Save multiple fields in different forms as uppercase when form is submitted
*/
add_action( 'gform_pre_submission_123', function ( $form ) { // Change 123 to your first form ID
$fields = array(2,9,12); // Enter your field IDs here, separated by commas. In this case it will apply to fields 2, 9 and 12
foreach( $fields as $field ){
$input_key = sprintf( 'input_%s', $field );
$_POST[ $input_key ] = strtoupper( rgpost( $input_key ) );
}
return $form;
} );
add_action( 'gform_pre_submission_456', function ( $form ) { // Change 456 to your second form ID
$fields = array(5,7); // Enter your field IDs here, separated by commas. In this case it will apply to fields 5 and 7
foreach( $fields as $field ){
$input_key = sprintf( 'input_%s', $field );
$_POST[ $input_key ] = strtoupper( rgpost( $input_key ) );
}
return $form;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment