I want to add custom error handling in acf backend. Here’s my code:
function dfg_acf_validate_value( $valid, $value, $field, $input_name ) {
// Bail early if value is already invalid.
if( $valid !== true ) {
return $valid;
}
if( $value != '30' and $value != 360 ) {
return __( 'Please choose a valid type!' );
}
return $valid;
}
add_filter('acf/validate_value/name=dfg_service_type', 'dfg_acf_validate_value', 10, 4);
and in the backend when I choose something else (instead of 30 or 360) nothing happens. What’s the reason for that?
I actually found that the hook is not fired. What’s the reason for that?
function dfg_acf_validate_value( $valid, $value, $field, $input_name ) {
if( $value != '30' ) {
wp_mail('test@example.com', 'subject', 'message');
}
return $valid;
}
add_filter('acf/validate_value/name=dfg_service_type', 'dfg_acf_validate_value', 10, 4);