preprocess_comment WordPress Filter Hook

The preprocess_comment hook is triggered before a comment is saved in the database. It allows you to modify the comment data before it is stored. This hook is useful for validating or filtering comments.

apply_filters( 'preprocess_comment', array $commentdata ) #

Filters a comment’s data before it is sanitized and inserted into the database.


Parameters

$commentdata

(array)Comment data.


Top ↑

More Information

The $commentdata array contains the following indices:

'comment_post_ID' - The post to which the comment will apply
'comment_author' - (may be empty)
'comment_author_email' - (may be empty)
'comment_author_url' - (may be empty)
'comment_content' - The text of the proposed comment
'comment_type' - 'pingback', 'trackback', or empty for regular comments
'user_ID' - (empty if not logged in)


Top ↑

Source

File: wp-includes/comment.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
5.6.0Comment data includes the comment_agent and comment_author_IP values.
1.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More