Non-CPT Comments
Regarding the first issue: you’re not returning anything if your conditional is false. To simplify your code:
function debate_comment_fields( $fields ) {
// If conditional is true
if( is_singular( 'debate' ) ) {
// Do some stuff to $fields
// Return $fields
return $fields;
}
// If conditional is not true?
}
add_filter('comment_form_default_fields','debate_comment_fields');
You need to return the default $fields
if your conditional is not true:
function debate_comment_fields( $fields ) {
// If conditional is true
if( is_singular( 'debate' ) ) {
// Do some stuff to $fields
// Return $fields
return $fields;
}
// If conditional is not true?
return $fields;
}
add_filter('comment_form_default_fields','debate_comment_fields');
This will ensure that the default fields are returned for non-CPT post comments.
CPT Comments
The second issue you’re running into is that, for your CPT comments, the comment form isn’t sending name and email, which are required. There are two solutions:
- Disable name/email as required fields globally
- Filter
preprocess_comment
to allow CPT post comments to bypass the required-field check