Hi,
I’m trying to show a custom ACF validation message.
The function below gets triggered and fails to save, but does not show the error message on the front-end (?) I deactivated all plugins and commented out all custom functions in functions.php. Is this a bug or am I overlooking something?
function custom_validate ( $valid, $value, $field, $input_name ) {
return __('this function should fail');
}
add_filter ('acf/validate_value/key=field_64ad703e1fab1', 'custom_validate', 10, 4);
Any solution? thnks!
Oke, validate_save_post seems to work.
function my_acf_validate_save_post() {
acf_add_validation_error( 'acf[field_64ad703e1fab1]', 'Please check?? this input to proceed' );
}
add_action('acf/validate_save_post', 'my_acf_validate_save_post');
Keeps me wondering though why add_filter (‘acf/validate_value’) is not working…
It could be that the key is incorrect.
Is this field that you are trying to validate a sub field of a repeater, flex or groups field?
Is this field a cloned field?
Try this
function custom_validate ($valid, $value, $field, $input_name) {
if (strpos($field['key'], 'field_64ad703e1fab1') !== false) {
return $field['key'];
}
return $valid;
}
add_filter ('acf/validate_value', 'custom_validate', 10, 4);