wp_get_comment_status( int|WP_Comment $comment_id )
The status of a comment by ID.
Description Description
Parameters Parameters
- $comment_id
-
(int|WP_Comment) (Required) Comment ID or WP_Comment object
Return Return
(false|string) Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
Source Source
File: wp-includes/comment.php
function wp_get_comment_status( $comment_id ) {
$comment = get_comment( $comment_id );
if ( ! $comment ) {
return false;
}
$approved = $comment->comment_approved;
if ( $approved == null ) {
return false;
} elseif ( $approved == '1' ) {
return 'approved';
} elseif ( $approved == '0' ) {
return 'unapproved';
} elseif ( $approved == 'spam' ) {
return 'spam';
} elseif ( $approved == 'trash' ) {
return 'trash';
} else {
return false;
}
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Check whether comment is approved
$status = wp_get_comment_status( $comment_id ); if ( 'approved' === $status ) { // Show the comment. }