acf/validate_value with acfe form
-
Hi,
I’m using acf/validate_value filter to check if a mail address already exists on an acfe form.function my_acf_validate_value_email( $valid, $value, $field, $input ) {
// Bail early if value is already invalid.
if( ! $valid ) {
return $valid;
}if ( isset( $_REQUEST[‘profil’] ) ) {
$profil = $_REQUEST[‘profil’];
} // endifif ( isset( $_REQUEST[‘user_id’] ) ) {
$user_id = intval( $_REQUEST[‘user_id’] );
}// Email aus der DB
$user_data = ( get_userdata( $user_id ) );
$user_email = $user_data -> user_email;if ( $profil == “edit” ) {
if ( $value == “” || $value == ” ” ) {
return “E-Mail-Feld darf nicht leer sein”;
} // endif
// Eamil nur prüfen, wenn neu ungleich alte Email
if ( $value != $user_email ) {
if( email_exists($value) ) {
return “Diese E-Mail existiert bereits. Verwende bitte eine andere E-Mail.”;
wp_die();
} // endif
} // endif
} // endifif ( $profil == “new” ) {
if( $value == “” || $value == ” ” ) {
return “E-Mail-Feld darf nicht leer sein”;
wp_die();
} // endif
if( email_exists($value) ) {
return “Diese E-Mail existiert bereits. Verwende bitte eine andere E-Mail.”;
wp_die();
} // endif
} // endifreturn $valid;
}
add_filter(‘acf/validate_value/key=field_6138824018e44’, ‘my_acf_validate_value_email’, 10, 4); // name=email`As return I don’t get an ajax-error message, instead I get the error page. Do I something wrong or is there an issue on acfe form validation?
thanks in advance
The topic ‘acf/validate_value with acfe form’ is closed to new replies.