wp_get_comment_status

The status of a comment by ID.

Description

(false|string) wp_get_comment_status( (int|WP_Comment) $comment_id ); 

Returns (false|string)

Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.

Parameters (1)

0. $comment_id (int|WP_Comment)
Comment ID or WP_Comment object

Usage

  1. if ( !function_exists( 'wp_get_comment_status' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment.php'; 
  3.  
  4. // Comment ID or WP_Comment object 
  5. $comment_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_get_comment_status($comment_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/comment.php  
  1. function wp_get_comment_status($comment_id) { 
  2. $comment = get_comment($comment_id); 
  3. if ( !$comment ) 
  4. return false; 
  5.  
  6. $approved = $comment->comment_approved; 
  7.  
  8. if ( $approved == null ) 
  9. return false; 
  10. elseif ( $approved == '1' ) 
  11. return 'approved'; 
  12. elseif ( $approved == '0' ) 
  13. return 'unapproved'; 
  14. elseif ( $approved == 'spam' ) 
  15. return 'spam'; 
  16. elseif ( $approved == 'trash' ) 
  17. return 'trash'; 
  18. else 
  19. return false;