spam_comment
Action HookDescription
Fires immediately before a comment is marked as Spam.Hook Information
File Location |
wp-includes/comment.php
View on GitHub
|
Hook Type | Action |
Line Number | 1693 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$comment_id
|
The comment ID. |
WP_Comment
|
$comment
|
The comment to be marked as spam. |
Usage Examples
Basic Usage
<?php
// Hook into spam_comment
add_action('spam_comment', 'my_custom_function', 10, 2);
function my_custom_function($comment_id, $comment) {
// Your custom code here
}
Source Code Context
wp-includes/comment.php:1693
- How this hook is used in WordPress core
<?php
1688 * @since 4.9.0 Added the `$comment` parameter.
1689 *
1690 * @param int $comment_id The comment ID.
1691 * @param WP_Comment $comment The comment to be marked as spam.
1692 */
1693 do_action( 'spam_comment', $comment->comment_ID, $comment );
1694
1695 if ( wp_set_comment_status( $comment, 'spam' ) ) {
1696 delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
1697 delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
1698 add_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved );
PHP Documentation
<?php
/**
* Fires immediately before a comment is marked as Spam.
*
* @since 2.9.0
* @since 4.9.0 Added the `$comment` parameter.
*
* @param int $comment_id The comment ID.
* @param WP_Comment $comment The comment to be marked as spam.
*/
Quick Info
- Hook Type: Action
- Parameters: 2
- File: wp-includes/comment.php
Related Hooks
Related hooks will be displayed here in future updates.