Hello,
Thanks for the feedback! You could probably achieve that using the native filter acf/validate_value
. See documentation.
Usage example:
add_filter('acf/validate_value/name=my_text', 'my_text_field_validate', 10, 4);
function my_text_field_validate($valid, $value, $field, $input_name){
// retrieve $_POST['acf']
$acf = acf_maybe_get_POST('acf', array());
// get taxonomy field using key and force it to array
$taxonomy = acf_maybe_get($acf, 'field_6100f527ff385');
$taxonomy = acf_get_array($taxonomy);
// if current value is empty and the Term ID 7 is in the taxonomy field
if(empty($value) && in_array(7, $taxonomy)){
// return an error
$valid = 'This field is required';
}
// return
return $valid;
}
Video demo: https://i.imgur.com/JI7aWAx.mp4
Hope it helps!
Have a nice day!
Regards.