I'd like to prevent posts under the default category named "affitti" to be published. I tried this but with no effect
function prevent_default_category_publish($data, $postarr) {
if (in_category('affitti', $postarr['ID'])) {
wp_die('Error: Posts cannot be published with the default category.');
}
return $data;
}
add_filter('wp_insert_post_data', 'prevent_default_category_publish', 10, 2);