Appearance
Documentation in progress - some sections may be incomplete or subject to change.
Modify comment data before a new comment is created.
Parameters:
$data
$requestData
Input Data Structure:
[ 'user_id' => 123, 'post_id' => 456, 'parent_id' => null, // or parent comment ID for replies 'message' => 'Comment text', 'type' => 'comment', 'status' => 'published', 'meta' => [] ]
Return Value: Modified array or WP_Error for validation errors
WP_Error
Example Usage:
// Validate minimum length add_filter('fluent_community/comment/comment_data', function($data, $requestData) { $message = strip_tags($data['message']); if (strlen($message) < 10) { return new WP_Error( 'comment_too_short', 'Comments must be at least 10 characters long', ['status' => 400] ); } return $data; }, 10, 2); // Block spam keywords add_filter('fluent_community/comment/comment_data', function($data, $requestData) { $spam_keywords = ['viagra', 'casino', 'lottery']; $message = strtolower($data['message']); foreach ($spam_keywords as $keyword) { if (stripos($message, $keyword) !== false) { return new WP_Error( 'spam_detected', 'Your comment contains prohibited content', ['status' => 403] ); } } return $data; }, 10, 2);
Modify comment data before an existing comment is updated.
$existingComment
Return Value: Modified array or WP_Error
Modify comments API response before sending to client.
$comments
$feed
Return Value: Modified comments array
Set maximum comment length in characters.
$maxLength
Return Value: Integer
Documentation in progress - some sections may be incomplete or subject to change.
Comments Filters
Comment Data Modification
fluent_community/comment/comment_data
Modify comment data before a new comment is created.
Parameters:
$data$requestDataInput Data Structure:
Return Value: Modified array or
WP_Errorfor validation errorsExample Usage:
fluent_community/comment/update_comment_data
Modify comment data before an existing comment is updated.
Parameters:
$data$existingComment$requestDataReturn Value: Modified array or
WP_ErrorAPI Response Filters
fluent_community/comments_query_response
Modify comments API response before sending to client.
Parameters:
$comments$feedReturn Value: Modified comments array
Configuration Filters
fluent_community/max_comment_char_length
Set maximum comment length in characters.
Parameters:
$maxLengthReturn Value: Integer
See Also