wppaste
WordPress

apply_filters( 'pre_comment_approved', int|string|WP_Error $approved, array $commentdata )

Since
2.1.0, 4.9.0
Filters a comment's approval status before it is set.

Compatibility

WordPress
since 4.9.0
  • 6.7.10
  • 6.8.11
  • 6.9.10
  • 7.0.7
  • 7.1.3

Present in every tracked release (6.7.10 to 7.1.3).

Parameters

$approvedint|string|WP_Error
The approval status. Accepts 1, 0, 'spam', 'trash', or WP_Error.
$commentdataarray
Comment data.

Where this hook fires · 1

  • wp-includes/comment.php:1309wp_check_comment_data()

Source code

	 *              and allow skipping further processing.	 *	 * @param int|string|WP_Error $approved    The approval status. Accepts 1, 0, 'spam', 'trash',	 *                                         or WP_Error.	 * @param array               $commentdata Comment data.	 */	return apply_filters( 'pre_comment_approved', $approved, $comment_data );} /** * Checks if a comment contains disallowed characters or words. * * @since 5.5.0

Changelog

Introduced in 2.1.0. Unchanged from 6.7.10 through 7.1.3.

  1. 6.7.10
  2. 6.8.11
  3. 6.9.10
  4. 7.0.7
  5. 7.1.3

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

4.9.0
Returning a WP_Error value from the filter will short-circuit comment insertion and allow skipping further processing.from the docblock
2.1.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.7.10 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.