pre_comment_approved
Filters a comment's approval status before it is set.
Usage
add_filter( 'pre_comment_approved', 'wp_kama_pre_comment_approved_filter', 10, 2 ); /** * Function for `pre_comment_approved` filter-hook. * * @param int|string|WP_Error $approved The approval status. Accepts 1, 0, 'spam', 'trash', or WP_Error. * @param array $commentdata Comment data. * * @return int|string|WP_Error */ function wp_kama_pre_comment_approved_filter( $approved, $commentdata ){ // filter... return $approved; }
- $approved(int|string|WP_Error)
- The approval status. Accepts 1, 0, 'spam', 'trash', or WP_Error.
- $commentdata(array)
- Comment data.
Changelog
Since 2.1.0 | Introduced. |
Since 4.9.0 | Returning a WP_Error value from the filter will short-circuit comment insertion and allow skipping further processing. |
Where the hook is called
pre_comment_approved
wp-includes/comment.php 1309
return apply_filters( 'pre_comment_approved', $approved, $comment_data );