Title: trash_comment
Published: April 25, 2014
Last modified: February 24, 2026

---

# do_action( ‘trash_comment’, string $comment_id, WP_Comment $comment )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/trash_comment/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/trash_comment/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/trash_comment/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/trash_comment/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/trash_comment/?output_format=md#user-contributed-notes)

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

Fires immediately before a comment is sent to the Trash.

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

 `$comment_id`string

The comment ID as a numeric string.

`$comment`[WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)

The comment to be trashed.

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

    ```php
    do_action( 'trash_comment', $comment->comment_ID, $comment );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/comment.php#L1625)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/comment.php#L1625-L1625)

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

| Used by | Description | 
| [wp_trash_comment()](https://developer.wordpress.org/reference/functions/wp_trash_comment/)`wp-includes/comment.php` |

Moves a comment to the Trash

  |

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

| Version | Description | 
| [4.9.0](https://developer.wordpress.org/reference/since/4.9.0/) | Added the `$comment` parameter. | 
| [2.9.0](https://developer.wordpress.org/reference/since/2.9.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/trash_comment/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/trash_comment/?output_format=md#comment-content-5286)
 2.   [hasanrang05](https://profiles.wordpress.org/hasanrang05/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/trash_comment/#comment-5286)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Ftrash_comment%2F%23comment-5286)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Ftrash_comment%2F%23comment-5286)
 4.     ```php
        function trash_comment_02092021( $comment_id, $comment ) {
    
            // do the code here
            error_log($comment_id);
    
        }
    
        add_action( 'spam_comment', 'trash_comment_02092021', 10, 2 );
        ```
    
 5.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Ftrash_comment%2F%3Freplytocom%3D5286%23feedback-editor-5286)

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