Support

Account

Home Forums Backend Issues (wp-admin) Checkbox limits per post type in admin

Unread

Checkbox limits per post type in admin

  • 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!

Viewing 1 post (of 1 total)

The topic ‘Checkbox limits per post type in admin’ is closed to new replies.