Title: WP_REST_Comments_Controller::check_is_comment_content_allowed
Published: December 9, 2020
Last modified: August 20, 2026

---

# WP_REST_Comments_Controller::check_is_comment_content_allowed( array $prepared_comment ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_is_comment_content_allowed/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_is_comment_content_allowed/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_is_comment_content_allowed/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_is_comment_content_allowed/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_is_comment_content_allowed/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_is_comment_content_allowed/?output_format=md#changelog)

If empty comments are not allowed, checks if the provided comment content is not
empty.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_is_comment_content_allowed/?output_format=md#parameters)󠁿

 `$prepared_comment`arrayrequired

The prepared comment data.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_is_comment_content_allowed/?output_format=md#return)󠁿

 bool True if the content is allowed, false otherwise.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_is_comment_content_allowed/?output_format=md#source)󠁿

    ```php
    protected function check_is_comment_content_allowed( $prepared_comment ) {
    	if ( ! isset( $prepared_comment['comment_content'] ) ) {
    		return true;
    	}

    	$check = wp_parse_args(
    		$prepared_comment,
    		array(
    			'comment_post_ID'      => 0,
    			'comment_author'       => null,
    			'comment_author_email' => null,
    			'comment_author_url'   => null,
    			'comment_parent'       => 0,
    			'user_id'              => 0,
    		)
    	);

    	/** This filter is documented in wp-includes/comment.php */
    	$allow_empty = apply_filters( 'allow_empty_comment', false, $check );

    	if ( $allow_empty ) {
    		return true;
    	}

    	// Allow empty notes only when resolution metadata is valid.
    	if (
    		isset( $check['comment_type'] ) &&
    		'note' === $check['comment_type'] &&
    		isset( $check['meta']['_wp_note_status'] ) &&
    		in_array( $check['meta']['_wp_note_status'], array( 'resolved', 'reopen' ), true )
    	) {
    		return true;
    	}

    	/*
    	 * Do not allow a comment to be created with missing or empty
    	 * comment_content. See wp_handle_comment_submission().
    	 */
    	return '' !== $check['comment_content'];
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php#L2003)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php#L2003-L2042)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_is_comment_content_allowed/?output_format=md#hooks)󠁿

 [apply_filters( ‘allow_empty_comment’, bool $allow_empty_comment, array $commentdata )](https://developer.wordpress.org/reference/hooks/allow_empty_comment/)

Filters whether an empty comment should be allowed.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_is_comment_content_allowed/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_parse_args()](https://developer.wordpress.org/reference/functions/wp_parse_args/)`wp-includes/functions.php` |

Merges user defined arguments into defaults array.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

| Used by | Description | 
| [WP_REST_Comments_Controller::update_item()](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/update_item/)`wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php` |

Updates a comment.

  | 
| [WP_REST_Comments_Controller::create_item()](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/create_item/)`wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php` |

Creates a comment.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_is_comment_content_allowed/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.6.0](https://developer.wordpress.org/reference/since/5.6.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_rest_comments_controller%2Fcheck_is_comment_content_allowed%2F)
before being able to contribute a note or feedback.