Action hook 'wp_set_comment_status'

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

View Source

wp_set_comment_status

Action Hook
Description
Fires immediately after transitioning a comment's status from one to another in the database and removing the comment from the object cache, but prior to all status transition hooks.

Hook Information

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

Hook Parameters

Type Name Description
string $comment_id Comment ID as a numeric string.
string $comment_status Current comment status. Possible values include 'hold', '0', 'approve', '1', 'spam', and 'trash'.

Usage Examples

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

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

Source Code Context

wp-includes/comment.php:2514 - How this hook is used in WordPress core
<?php
2509  	 *
2510  	 * @param string $comment_id     Comment ID as a numeric string.
2511  	 * @param string $comment_status Current comment status. Possible values include
2512  	 *                               'hold', '0', 'approve', '1', 'spam', and 'trash'.
2513  	 */
2514  	do_action( 'wp_set_comment_status', $comment->comment_ID, $comment_status );
2515  
2516  	wp_transition_comment_status( $comment_status, $comment_old->comment_approved, $comment );
2517  
2518  	wp_update_comment_count( $comment->comment_post_ID );
2519  

PHP Documentation

<?php
/**
	 * Fires immediately after transitioning a comment's status from one to another in the database
	 * and removing the comment from the object cache, but prior to all status transition hooks.
	 *
	 * @since 1.5.0
	 *
	 * @param string $comment_id     Comment ID as a numeric string.
	 * @param string $comment_status Current comment status. Possible values include
	 *                               'hold', '0', 'approve', '1', 'spam', and 'trash'.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 2
  • File: wp-includes/comment.php
Related Hooks

Related hooks will be displayed here in future updates.