maurotello73
Forum Replies Created
-
I had put a similar code in the function but that’s when it throws the error .. as long as I have attachments loaded, it tells me that there is no field filled in, when in fact there are all required fields .. but it only happens to me when the error I add it in the validation of those emails, with the rest it works well for me. I pass the code that I have in the function, where I have other validations
add_filter(‘forminator_custom_form_submit_errors’, ‘my_custom_form_validation’, 99, 3);
function my_custom_form_validation($submit_errors, $form_id, $field_data_array) {
// Skip if is not the correct form
if( (int) $form_id !== 2643 ){
return;
}$fields = [];
$fields[] = $_POST[’email-1′];
$fields[] = $_POST[’email-2′];
$conyuge = $_POST[‘checkbox-3’];
$hijo1 = $_POST[‘checkbox-4’];
$hijo2 = $_POST[‘checkbox-5’];
$hijo3 = $_POST[‘checkbox-6’];
$hijo4 = $_POST[‘checkbox-8’];if (isset($conyuge)){
if ($_POST[‘name-2’] == null){
$submit_errors[][‘name-2’] = __( ‘Campo obligatorio porque tiene activo cónyuge’ );
}
if ($_POST[‘number-2’] == null){
$submit_errors[][‘number-2’] = __( ‘Campo obligatorio porque tiene activo cónyuge’ );
}}
if (isset($hijo1)){
if ($_POST[‘name-3’] == null){
$submit_errors[][‘name-3’] = __( ‘Campo obligatorio porque tiene activo primer hijo’ );
}
if ($_POST[‘number-3’] == null){
$submit_errors[][‘number-3’] = __( ‘Campo obligatorio porque tiene activo primer hijo’ );
}}
if (isset($hijo2)){
if ($_POST[‘name-4’] == null){
$submit_errors[][‘name-4’] = __( ‘Campo obligatorio porque tiene activo segundo hijo’ );
}
if ($_POST[‘number-4’] == null){
$submit_errors[][‘number-4’] = __( ‘Campo obligatorio porque tiene activo segundo hijo’ );
}}
if (isset($hijo3)){
if ($_POST[‘name-5’] == null){
$submit_errors[][‘name-5’] = __( ‘Campo obligatorio porque tiene activo tercer hijo’ );
}
if ($_POST[‘number-5’] == null){
$submit_errors[][‘number-5’] = __( ‘Campo obligatorio porque tiene activo tercer hijo’ );
}}
if (isset($hijo4)){
if ($_POST[‘name-6’] == null){
$submit_errors[][‘name-6’] = __( ‘Campo obligatorio porque tiene activo cuarto hijo’ );
}
if ($_POST[‘number-6’] == null){
$submit_errors[][‘number-6’] = __( ‘Campo obligatorio porque tiene activo cuarto hijo’ );
}}
// Check if both emails are the same
/*
if (count(array_unique($fields)) !== 1) {
// Custom error
$submit_errors[][ ’email-2′] = __( ‘Las casillas de Email no son iguales’ );
}*/$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′] = __( ‘Los emails cargados no son iguales’ );
}// Always return $submit_errors
return $submit_errors;}
When it enters that validation of the same emails it throws me the error, that is, the first error that it throws me is fine, it is telling me that the emails without different, so far perfect, but when I correct the emails and press send again .. There is where the second error appears that tells me that I must complete some of the fields .. it is like it loses the value of the fields already completed before the error of the same emails. At sight they are, that is, I can see that the fields are complete, but when I press SEND (after correcting the error in the mails) this second error jumps .. I reiterate for me it is like it loses the values of the fields
- This reply was modified 3 years, 4 months ago by maurotello73.
@wpmudev-support8
Sorry in which folder? I have wp-content / forminator. Could you give me an email so I can explain you better?- This reply was modified 3 years, 4 months ago by maurotello73.
Hello I wanted to ask @guiri-express if he could help me to create a new TAB in the profile, because I could not do it