Action hook 'untrash_comment'

in WP Core File wp-includes/comment.php at line 1642

View Source

untrash_comment

Action Hook
Description
Fires immediately before a comment is restored from the Trash.

Hook Information

File Location wp-includes/comment.php View on GitHub
Hook Type Action
Line Number 1642

Hook Parameters

Type Name Description
string $comment_id The comment ID as a numeric string.
WP_Comment $comment The comment to be untrashed.

Usage Examples

Basic Usage
<?php
// Hook into untrash_comment
add_action('untrash_comment', 'my_custom_function', 10, 2);

function my_custom_function($comment_id, $comment) {
    // Your custom code here
}

Source Code Context

wp-includes/comment.php:1642 - How this hook is used in WordPress core
<?php
1637  	 * @since 4.9.0 Added the `$comment` parameter.
1638  	 *
1639  	 * @param string     $comment_id The comment ID as a numeric string.
1640  	 * @param WP_Comment $comment    The comment to be untrashed.
1641  	 */
1642  	do_action( 'untrash_comment', $comment->comment_ID, $comment );
1643  
1644  	$status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
1645  	if ( empty( $status ) ) {
1646  		$status = '0';
1647  	}

PHP Documentation

<?php
/**
	 * Fires immediately before a comment is restored from the Trash.
	 *
	 * @since 2.9.0
	 * @since 4.9.0 Added the `$comment` parameter.
	 *
	 * @param string     $comment_id The comment ID as a numeric string.
	 * @param WP_Comment $comment    The comment to be untrashed.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 2
  • File: wp-includes/comment.php
Related Hooks

Related hooks will be displayed here in future updates.