Hello @pabloandres86 !
Hope you’re doing well today!
We’ve had some requests for that feature, but it’s not available yet out of the box. I’ll add your ticket on the task we have to notify the Forminator team of the interest in this.
In the meantime, please try the following snippet:
<?php
add_filter( 'forminator_custom_form_submit_errors', function( $submit_errors, $form_id, $field_data_array ) {
$use_on_forms = [ 123, 234 ];
$field1 = 'email-1';
$field2 = 'email-2';
if( ! in_array( $form_id, $use_on_forms) ) {
return $submit_errors;
}
$email1 = $email2 = '';
foreach( $field_data_array as $arr ) {
if( $arr['name'] == $field1 ) $email1 = $arr['value'];
if( $arr['name'] == $field2 ) $email2 = $arr['value'];
if( '' != $email1 && '' != $email2 ) break;
}
if( $email1 != $email2 ) {
$submit_errors[][$field2] = 'The email addresses must match!';
}
return $submit_errors;
}, 99, 3);
To install:
– copy the code to a .php file
– create 2 email fields on the form
– adjust the values to match your case:
$use_on_forms = [ 123, 234 ]; // include any number of form IDs where this snippet should be used (you can find those in the URL of the form's edit screen or in the shortcode)
$field1 = 'email-1'; // make sure those two match your form's fields
$field2 = 'email-2';
– create the wp-content/mu-plugins directory if it doesn’t exist
– upload the snippet to the mu-plugins directory
Kind regards,
Pawel