wppaste
WordPress

apply_filters( 'allow_empty_comment', bool $allow_empty_comment, array $commentdata )

Since
5.1.0
Filters whether an empty comment should be allowed.

Compatibility

WordPress
since 5.1.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$allow_empty_commentbool
Whether to allow empty comments. Default false.
$commentdataarray
Array of comment data to be sent to wp_insert_comment().

Where this hook fires · 3

  • wp-includes/class-wp-xmlrpc-server.php:4020wp_xmlrpc_server::wp_newComment()
  • wp-includes/comment.php:3799wp_handle_comment_submission()
  • wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:2021WP_REST_Comments_Controller::check_is_comment_content_allowed()

Source code

	 *	 * @since 5.1.0	 *	 * @param bool  $allow_empty_comment Whether to allow empty comments. Default false.	 * @param array $commentdata         Array of comment data to be sent to wp_insert_comment().	 */	$allow_empty_comment = apply_filters( 'allow_empty_comment', false, $commentdata );	if ( '' === $comment_content && ! $allow_empty_comment ) {		return new WP_Error( 'require_valid_comment', __( '<strong>Error:</strong> Please type your comment text.' ), 200 );	} 	$check_max_lengths = wp_check_comment_data_max_lengths( $commentdata );	if ( is_wp_error( $check_max_lengths ) ) {

Changelog

Introduced in 5.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.