Title: rest_preprocess_comment
Published: December 6, 2016
Last modified: May 20, 2026

---

# apply_filters( ‘rest_preprocess_comment’, array $prepared_comment, WP_REST_Request $request )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/rest_preprocess_comment/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/rest_preprocess_comment/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/rest_preprocess_comment/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/rest_preprocess_comment/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/rest_preprocess_comment/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/hooks/rest_preprocess_comment/?output_format=md#wp--skip-link--target)

Filters a comment added via the REST API after it is prepared for insertion into
the database.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/rest_preprocess_comment/?output_format=md#description)󠁿

Allows modification of the comment right after it is prepared for the database.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/rest_preprocess_comment/?output_format=md#parameters)󠁿

 `$prepared_comment`array

The prepared comment data for `wp_insert_comment`.

`$request`[WP_REST_Request](https://developer.wordpress.org/reference/classes/wp_rest_request/)

The current request.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/rest_preprocess_comment/?output_format=md#source)󠁿

    ```php
    return apply_filters( 'rest_preprocess_comment', $prepared_comment, $request );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php#L1485)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php#L1485-L1485)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/rest_preprocess_comment/?output_format=md#related)󠁿

| Used by | Description | 
| [WP_REST_Comments_Controller::prepare_item_for_database()](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/prepare_item_for_database/)`wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php` |

Prepares a single comment to be inserted into the database.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/rest_preprocess_comment/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Frest_preprocess_comment%2F)
before being able to contribute a note or feedback.