Home › Forums › Bug Reports › Allow null for multisite taxonomy select › Reply To: Allow null for multisite taxonomy select
Support led me in the right direction – I added a custom validation to that field, works like a charm
//**********Custom Validation for Taxonomy Field
add_filter('acf/validate_value/type=taxonomy', 'my_acf_validate_taxonomy', 10, 4);
function my_acf_validate_taxonomy( $valid, $value, $field, $input ){
// bail early if value is already invalid
if( !$valid ) {
return $valid;
}
$terms = get_terms( array(
'taxonomy' => $field['taxonomy'],
'hide_empty' => false,
) );
if( count($terms) > 0 ) {
if(!$value) {
$valid = 'Please select a category';
}
}
// return
return $valid;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.