rest_preprocess_comment
Filter HookDescription
Filters a comment added via the REST API after it is prepared for insertion into the database. Allows modification of the comment right after it is prepared for the database.Hook Information
| File Location |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
View on GitHub
|
| Hook Type | Filter |
| Line Number | 1388 |
Hook Parameters
| Type | Name | Description |
|---|---|---|
array
|
$prepared_comment
|
The prepared comment data for `wp_insert_comment`. |
WP_REST_Request
|
$request
|
The current request. |
Usage Examples
Basic Usage
<?php
// Hook into rest_preprocess_comment
add_filter('rest_preprocess_comment', 'my_custom_filter', 10, 2);
function my_custom_filter($prepared_comment, $request) {
// Your custom filtering logic here
return $prepared_comment;
}
Source Code Context
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:1388
- How this hook is used in WordPress core
<?php
1383 * @since 4.7.0
1384 *
1385 * @param array $prepared_comment The prepared comment data for `wp_insert_comment`.
1386 * @param WP_REST_Request $request The current request.
1387 */
1388 return apply_filters( 'rest_preprocess_comment', $prepared_comment, $request );
1389 }
1390
1391 /**
1392 * Retrieves the comment's schema, conforming to JSON Schema.
1393 *
PHP Documentation
<?php
/**
* Filters a comment added via the REST API after it is prepared for insertion into the database.
*
* Allows modification of the comment right after it is prepared for the database.
*
* @since 4.7.0
*
* @param array $prepared_comment The prepared comment data for `wp_insert_comment`.
* @param WP_REST_Request $request The current request.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
Related Hooks
Related hooks will be displayed here in future updates.