WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp set comment status

Contents

Description

Sets the status of a comment.

The 'wp_set_comment_status' action is called after the comment is handled and will only be called, if the comment status is either 'hold', 'approve', or 'spam'. If the comment status is not in the list, then false is returned and if the status is 'delete', then the comment is deleted without calling the action.

Usage

<?php wp_set_comment_status$comment_id$comment_status ?>

Parameters

$comment_id
(integer) (required) Comment ID.
Default: None
$comment_status
(string) (required) New comment status, either 'hold', 'approve', 'spam', or 'trash'.
Default: None

Return Values

(boolean) 
False on failure or deletion and true on success.

Examples

Notes

Change Log

  • Since 2.9: $comment_status: the parameter 'delete' was replaced with 'trash'. Comments will be added to the Comment Trash instead of being purged from the database.
  • Since: 1.0.0

Source File

wp_set_comment_status() is located in wp-includes/comment.php.

Related

 

See also index of Function Reference and index of Template Tags.