Last active
April 25, 2023 12:30
-
-
Save matty0501/a48dd2eaaaa5870c9e934994b30a8f04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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