I have tried to setup checkbox limits per post type, it’s working but the $valid doesn’t show the noti if the limits are reached.
add_filter('acf/validate_value/name=specialty', 'only_allow_checkbox', 20, 4);
function only_allow_checkbox($valid, $value, $field, $input) {
if( !$valid ) {
return $valid;
}
$screen = get_current_screen();
if (count($value) > 3 && ($screen->post_type == 'technology') ) {
$valid = 'Only Select 3';
} else if (count($value) > 2) {
$valid = 'Only Select 2';
}
return $valid;
}
I need your help, thank you so much!