Created
April 18, 2022 11:55
-
-
Save adczk/409dba81b8131e21660a39e15f5f5d21 to your computer and use it in GitHub Desktop.
Forminator - compare two e-mail fields if they are the same
This file contains hidden or 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 | |
| /************************************ | |
| * | |
| * Forminator - compare two e-mail fields to confirm; if different, issue error | |
| * | |
| * by adamcz/WPMU DEV | |
| * Tested with Forminator 1.15.12 | |
| * | |
| * Use as MU plugin | |
| * | |
| * Adjust fields' IDs if needed to match your form | |
| * | |
| *********************************/ | |
| add_filter( 'forminator_custom_form_submit_errors', 'check_form_data', 99, 3 ); | |
| function check_form_data( $submit_errors, $form_id, $field_data_array ) { | |
| $email1 = $email2 = ''; | |
| foreach( $field_data_array as $arr ) { | |
| if( $arr['name'] == 'email-1' ) $email1 = $arr['value']; | |
| if( $arr['name'] == 'email-2' ) $email2 = $arr['value']; | |
| if( '' != $email1 && '' != $email2 ) break; | |
| } | |
| if( $email1 != $email2 ) { | |
| $submit_errors[]['email-2'] = 'The email addresses must match!'; | |
| } | |
| return $submit_errors; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment