I’ve read the documentation concerning doing a custom validation on an acf_form: http://www.advancedcustomfields.com/resources/acf-validate_value/.
I put below code in my functions.php and added and ACF image field called “validate_this_image” to my ACF front-end form.
When I submit the form with an image smaller than 960px, not any validation is happening? No error? It just submits and adds the values in WP. Do I miss something?
add_filter('acf/validate_value/name=validate_this_image', 'my_acf_validate_value', 10, 4);
function my_acf_validate_value( $valid, $value, $field, $input ){
// bail early if value is already invalid
if( !$valid ) {
return $valid;
}
// load image data
$data = wp_get_attachment_image_src( $value, 'full' );
$width = $data[1];
$height = $data[2];
if( $width < 960 ) {
$valid = 'Image must be at least 960px wide';
}
// return
return $valid;
}
UP
I have exactly the same problem :
add_filter('acf/validate_value', 'My_validate_annonce', 10, 4 );
function My_validate_dates_annonce( $valid, $value, $field, $input ){
if( 1 )
return 'erreur !';
}
That do nothing…
It the same if I put this code :
add_filter('acf/validate_value/name=my_date_debut_annonce', 'My_validate_annonce', 10, 4 );
function My_validate_dates_annonce( $valid, $value, $field, $input ){
if( 1 )
return 'erreur !';
}