Hi @ibby
I hope you’re well today!
There’s no e-mail confirmation field out of the box but it is doable with a small bit of additional code:
1. add second e-mail field to the form
2. then add code as a Must-Use plugin to the site:
– create an empty file with a .php extension (e.g. “forminator-confirm-email.php”)
– copy and paste following code into it
<?php
add_filter( 'forminator_custom_form_submit_errors', 'check_form_data', 99, 3 );
function check_form_data( $submit_errors, $form_id, $field_data_array ) {
if ( $form_id<> 123 )
return $submit_errors;
$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;
}
– in this line replace 123 with your form ID (it’s the number you see in form’s shortcode)
if ( $form_id<> 123 )
– in these lines replace email-1 and email-2 with your e-mail fields IDs if they are different
if( $arr['name'] == 'email-1' ) $email1 = $arr['value'];
if( $arr['name'] == 'email-2' ) $email2 = $arr['value'];
– and in this one you can adjust error message (note, make sure that email-2 here is also replaced with and ID of second e-mail field if necessary)
$submit_errors[]['email-2'] = 'The email addresses must match!';
– finally, save the file and upload it to the “/wp-content/mu-plugins” folder of your site’s WordPress installation.
It should work out of the box and if one of the fields is empty or it has different e-mail address than the other, it should issue the error and prevent form submission.
Best regards,
Adam