acf/validate_value with acfe form | WordPress.org

[ad_1]

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’];
} // endif

if ( 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
} // endif

if ( $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
} // endif

return $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

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer