Support

Account

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;
    }