Skip to content

Comments Filters

13 unique filter hooks currently map to this category, across 13 call sites.

Hook Inventory

HookEditionCall SitesFirst Source
fluent_community/comment_api_responseCore1fluent-community/app/Http/Controllers/CommentsController.php:734
fluent_community/comment_order_optionsCore1fluent-community/app/Services/Helper.php:2273
fluent_community/comment/comment_dataCore1fluent-community/app/Http/Controllers/CommentsController.php:140
fluent_community/comment/new_comment_responseCore1fluent-community/app/Http/Controllers/CommentsController.php:177
fluent_community/comment/patch_comment_responseCore1fluent-community/app/Http/Controllers/CommentsController.php:334
fluent_community/comment/update_comment_dataCore1fluent-community/app/Http/Controllers/CommentsController.php:225
fluent_community/comments_api_responseCore1fluent-community/app/Http/Controllers/CommentsController.php:71
fluent_community/comments_query_responseCore1fluent-community/app/Http/Controllers/CommentsController.php:52
fluent_community/disable_duplicate_comment_checkCore1fluent-community/app/Http/Controllers/CommentsController.php:94
fluent_community/disable_self_comment_reactCore1fluent-community/app/Http/Controllers/CommentsController.php:633
fluent_community/max_comment_char_lengthCore1fluent-community/app/Http/Controllers/CommentsController.php:448
fluent_community/profile_comments_api_responseCore1fluent-community/app/Http/Controllers/ProfileController.php:713
fluent_community/rate_limit/comments_per_minuteCore1fluent-community/app/Hooks/Handlers/RateLimitHandler.php:49

fluent_community/comment_api_response

  • Type: filter
  • Edition: Core
  • Call sites: 1
  • When it fires: Filters the single-comment response.

Serves the endpoint the portal calls when deep-linking to a comment and when opening one for editing. With context=edit the payload has been reshaped first: meta is unset and any attached images are lifted onto a media_images property, or a non-uploader preview is put back under meta.media_preview. Access is verified against the parent post before the filter runs.

Parameters

#NameTypeDescription
1$dataarrayResponse payload with a comment key.
2$requestDataarrayThe full request parameters, including context.

Return: The response payload array.

Call Sites

EditionSourceParameters
Corefluent-community/app/Http/Controllers/CommentsController.php:734$data (mixed)
$request->all() (array)

Example

php
add_filter('fluent_community/comment_api_response', function ($data, $requestData) {
    return $data;
}, 10, 2);

Related: fluent_community/comments_api_response

fluent_community/comment_order_options

  • Type: filter
  • Edition: Core
  • Call sites: 1
  • When it fires: Filters the comment sort options a space administrator can choose from as that space's default.

Defaults to oldest (labelled "Earliest"), latest, popular and most_replied. It reaches the portal as comment_order_by_options, and the only consumer is the space settings form. The reader-facing sort dropdown is hard-coded in the Vue components and the sorting itself is done client-side, so adding a key here makes it selectable as a space default but nothing will know how to apply it. Removing keys is the safe direction. $context is comment at the only current call site.

Parameters

#NameTypeDescription
1$optionsarraySort keys mapped to translated labels.
2$contextstringThe list being sorted; comment today.

Return: array — an associative map of sort key to label, preserving order.

Call Sites

EditionSourceParameters
Corefluent-community/app/Services/Helper.php:2273$options (mixed)
$context (mixed)

Example

php
add_filter('fluent_community/comment_order_options', function ($options, $context) {
    return $options;
}, 10, 2);

Related: fluent_community/portal_vars

fluent_community/comment/comment_data

  • Type: filter
  • Edition: Core
  • Call sites: 1
  • When it fires: Filters the attributes a new comment is about to be created from.

The pre-save hook for comments, applied immediately after the read-only fluent_community/before_comment_create action. Setting status to something other than published here diverts the request into the held-comment branch — that is how Pro's moderation holds a comment back. There is no WP_Error contract: unlike the post-side filters, whatever you return is passed straight to Comment::create(), so throw if you need to abort.

Parameters

#NameTypeDescription
1$commentDataarrayThe attributes to create the comment with: post_id, message, message_rendered, parent_id, is_admin, meta, status.
2$feed\FluentCommunity\App\Models\FeedThe post being commented on.

Return: array — the attribute map. It is not validated, so unknown keys will reach the model.

Call Sites

EditionSourceParameters
Corefluent-community/app/Http/Controllers/CommentsController.php:140$commentData (mixed)
$feed (Feed)

Example

php
add_filter('fluent_community/comment/comment_data', function ($commentData, $feed) {
    return $commentData;
}, 10, 2);

Related: fluent_community/comment/update_comment_data · fluent_community/before_comment_create

fluent_community/comment/new_comment_response

  • Type: filter
  • Edition: Core
  • Call sites: 1
  • When it fires: Filters the response returned when a new comment is not published.

Only applied on the held-for-moderation branch. The success path returns its payload without any filter at all, so this is not a general "comment created" response hook — it exists so Pro can explain to the author why their comment is pending. The comment value is the raw model with its relations loaded.

Parameters

#NameTypeDescription
1$responsearrayResponse payload: comment and message.
2$comment\FluentCommunity\App\Models\CommentThe stored comment, in its non-published status.

Return: The response payload array.

Call Sites

EditionSourceParameters
Corefluent-community/app/Http/Controllers/CommentsController.php:177$response (mixed)
$comment (Comment)

Example

php
add_filter('fluent_community/comment/new_comment_response', function ($response, $comment) {
    return $response;
}, 10, 2);

Related: fluent_community/comment/new_comment_{comment} · fluent_community/comment/patch_comment_response

fluent_community/comment/patch_comment_response

  • Type: filter
  • Edition: Core
  • Call sites: 1
  • When it fires: Filters the response of the comment patch endpoint.

The patch endpoint handles the pin toggle only and is restricted to moderators and admins. The filter is applied whether or not anything changed, and receives four arguments — note that the request data is last, not second as in most response filters.

Parameters

#NameTypeDescription
1$responsearrayResponse payload: comment and message.
2$comment\FluentCommunity\App\Models\CommentThe comment after the patch.
3$feed\FluentCommunity\App\Models\FeedThe post the comment belongs to.
4$requestDataarrayThe full request parameters.

Return: The response payload array.

Call Sites

EditionSourceParameters
Corefluent-community/app/Http/Controllers/CommentsController.php:334array (2 keys: comment, message) (array)
$comment (Comment)
$feed (Feed)
$request->all() (array)

Example

php
add_filter('fluent_community/comment/patch_comment_response', function ($response, $comment, $feed, $requestData) {
    return $response;
}, 10, 4);

Related: fluent_community/comment/updated

fluent_community/comment/update_comment_data

  • Type: filter
  • Edition: Core
  • Call sites: 1
  • When it fires: Filters the attributes an edited comment is about to be saved with.

The update-side twin of fluent_community/comment/comment_data, with two extra arguments. What you return is filled onto the model and determines the dirty check, so returning the attributes unchanged makes the edit a silent no-op that fires neither fluent_community/comment_updated nor its type-scoped twin. Pro uses it to re-flag an edited comment.

Parameters

#NameTypeDescription
1$commentDataarrayThe attributes for the edit.
2$feed\FluentCommunity\App\Models\FeedThe post the comment belongs to.
3$requestDataarrayThe full request payload; carries is_admin.
4$comment\FluentCommunity\App\Models\CommentThe comment as currently stored.

Return: array — the attribute map.

Call Sites

EditionSourceParameters
Corefluent-community/app/Http/Controllers/CommentsController.php:225$commentData (mixed)
$feed (Feed)
$requestData (array)
$comment (Comment)

Example

php
add_filter('fluent_community/comment/update_comment_data', function ($commentData, $feed, $requestData, $comment) {
    return $commentData;
}, 10, 4);

Related: fluent_community/comment/comment_data

fluent_community/comments_api_response

  • Type: filter
  • Edition: Core
  • Call sites: 1
  • When it fires: Filters the comment listing response for one post.

The endpoint returns every comment on the post in one go — there is no paging, and sorting is done client side — so on a busy thread the payload can be large. Replies are flat in the list, distinguished by parent_id. When fluent_community/can_view_comments_{type} denies access the endpoint returns an empty list early and this filter never runs.

Parameters

#NameTypeDescription
1$dataarrayResponse payload with a comments collection.
2$requestDataarrayThe full request parameters.

Return: The response payload array.

Call Sites

EditionSourceParameters
Corefluent-community/app/Http/Controllers/CommentsController.php:71$data (mixed)
$request->all() (array)

Example

php
add_filter('fluent_community/comments_api_response', function ($data, $requestData) {
    return $data;
}, 10, 2);

Related: fluent_community/comments_query_response · fluent_community/can_view_comments_{feed}

fluent_community/comments_query_response

  • Type: filter
  • Edition: Core
  • Call sites: 1
  • When it fires: Filters the comment collection for a post before the viewer's likes are marked on it.

Receives an Eloquent collection of Comment models, not an array and not a response payload — return a collection or the each() call that follows will fail. It runs after moderation-status scoping and after inactive-profile comments have been excluded, which makes it the right place to drop or reorder comments; fluent_community/comments_api_response is the place to reshape the response.

Parameters

#NameTypeDescription
1$comments\FluentCommunity\Framework\Database\Orm\CollectionThe post's comments, with xprofile eager-loaded.
2$requestDataarrayThe full request parameters.

Return: The comment collection.

Call Sites

EditionSourceParameters
Corefluent-community/app/Http/Controllers/CommentsController.php:52$comments (mixed)
$request->all() (array)

Example

php
add_filter('fluent_community/comments_query_response', function ($comments, $requestData) {
    return $comments;
}, 10, 2);

Related: fluent_community/comments_api_response

fluent_community/disable_duplicate_comment_check

  • Type: filter
  • Edition: Core
  • Call sites: 1
  • When it fires: Filters whether the identical-comment guard is skipped for this submission.

By default a comment whose body exactly matches an earlier comment by the same user on the same post is rejected with "No duplicate comment please!". The check only runs when the comment has text, so image-only replies bypass it regardless. Return true to skip it — useful for short affirmations such as "thanks" in busy spaces.

Parameters

#NameTypeDescription
1$skipCheckboolWhether to skip the duplicate check. false by default.
2$userIdintThe commenting user's ID.
3$feedIdintThe post being commented on.

Return: booltrue to allow the duplicate through.

Call Sites

EditionSourceParameters
Corefluent-community/app/Http/Controllers/CommentsController.php:94false (bool)
get_current_user_id() (int)
$feed->id (int)

Example

php
add_filter('fluent_community/disable_duplicate_comment_check', function ($skipCheck, $userId, $feedId) {
    return $skipCheck;
}, 10, 3);

Related: fluent_community/rate_limit/comments_per_minute

fluent_community/disable_self_comment_react

  • Type: filter
  • Edition: Core
  • Call sites: 1
  • When it fires: Filters whether users are barred from reacting to their own comments.

The name reads as a switch that is on by default, but it is not: it defaults to false, meaning self-reacting is permitted. Return true to block it, at which point the API responds with an error. It applies to comment reactions only — reactions on the user's own posts are unaffected.

Parameters

#NameTypeDescription
1$disabledboolWhether to reject the reaction. false by default, so self-reacting is allowed.
2$feed\FluentCommunity\App\Models\FeedThe post the comment belongs to, so the rule can be scoped per space.

Return: booltrue to reject a reaction on the user's own comment.

Call Sites

EditionSourceParameters
Corefluent-community/app/Http/Controllers/CommentsController.php:633false (bool)
$feed (Feed)

Example

php
add_filter('fluent_community/disable_self_comment_react', function ($disabled, $feed) {
    return $disabled;
}, 10, 2);

fluent_community/max_comment_char_length

  • Type: filter
  • Edition: Core
  • Call sites: 1
  • When it fires: Filters the maximum number of characters allowed in a comment or reply.

Defaults to 10000 and, like the post limit, is measured with strlen() on the Markdown source, so it is a byte count. Exceeding it throws a 422 before the comment is stored. It applies to both new comments and edits, since both run through the same validation routine.

Parameters

#NameTypeDescription
1$maxLengthintThe byte ceiling for a comment body, 10000 by default.

Return: int — the maximum length.

Call Sites

EditionSourceParameters
Corefluent-community/app/Http/Controllers/CommentsController.php:44810000 (int)

Example

php
add_filter('fluent_community/max_comment_char_length', function ($maxLength) {
    return $maxLength;
}, 10, 1);

Related: fluent_community/max_post_length

fluent_community/profile_comments_api_response

  • Type: filter
  • Edition: Core
  • Call sites: 1
  • When it fires: Filters the comment listing shown on a member profile.

Scoped to comments on plain text posts the viewer may access, newest first, and paginated. The payload carries the paginator plus the profile itself. The parent posts of the listed comments have already been run through FeedsHelper::transformFeedsCollection(), so they are hydrated in place on each comment's post relation.

Parameters

#NameTypeDescription
1$dataarrayResponse payload: comments paginator and xprofile.
2$requestDataarrayThe full request parameters.

Return: The response payload array.

Call Sites

EditionSourceParameters
Corefluent-community/app/Http/Controllers/ProfileController.php:713$data (mixed)
$request->all() (array)

Example

php
add_filter('fluent_community/profile_comments_api_response', function ($data, $requestData) {
    return $data;
}, 10, 2);

Related: fluent_community/comments_api_response

fluent_community/rate_limit/comments_per_minute

  • Type: filter
  • Edition: Core
  • Call sites: 1
  • When it fires: Filters how many comments a member may post in a rolling one-minute window.

Defaults to 5. The comparison is count > limit against comments created in the last 60 seconds, so the effective allowance is one more than the number returned — the default lets six through before the sixth attempt is refused. Site administrators are exempt before the filter is reached, and exceeding the limit throws rather than returning a structured error.

Parameters

#NameTypeDescription
1$limitPerMinuteintComments allowed per rolling minute, 5 by default.

Return: int — the limit. A very large value effectively disables comment rate limiting.

Call Sites

EditionSourceParameters
Corefluent-community/app/Hooks/Handlers/RateLimitHandler.php:495 (int)

Example

php
add_filter('fluent_community/rate_limit/comments_per_minute', function ($limitPerMinute) {
    return $limitPerMinute;
}, 10, 1);

Related: fluent_community/disable_duplicate_comment_check

FluentCommunity developer documentation