Filter hook 'allow_empty_comment'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php at line 1919

View Source

allow_empty_comment

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

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php View on GitHub
Hook Type Filter
Line Number 1919

Hook Parameters

Type Name Description
array $prepared_comment The prepared comment data.

Usage Examples

Basic Usage
<?php
// Hook into allow_empty_comment
add_filter('allow_empty_comment', 'my_custom_filter', 10, 1);

function my_custom_filter($prepared_comment) {
    // Your custom filtering logic here
    return $prepared_comment;
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:1919 - How this hook is used in WordPress core
<?php
1914  				'user_id'              => 0,
1915  			)
1916  		);
1917  
1918  		/** This filter is documented in wp-includes/comment.php */
1919  		$allow_empty = apply_filters( 'allow_empty_comment', false, $check );
1920  
1921  		if ( $allow_empty ) {
1922  			return true;
1923  		}
1924  

PHP Documentation

<?php
/**
	 * If empty comments are not allowed, checks if the provided comment content is not empty.
	 *
	 * @since 5.6.0
	 *
	 * @param array $prepared_comment The prepared comment data.
	 * @return bool True if the content is allowed, false otherwise.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
Related Hooks

Related hooks will be displayed here in future updates.