wp_get_comment_status()
Retrieves the status of a comment by comment ID.
No Hooks.
Return
String|false
. Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
Usage
wp_get_comment_status( $comment_id );
- $comment_id(int|WP_Comment) (required)
- Comment ID or WP_Comment object
Changelog
Since 1.0.0 | Introduced. |
wp_get_comment_status() wp get comment status code WP 6.7.1
function wp_get_comment_status( $comment_id ) { $comment = get_comment( $comment_id ); if ( ! $comment ) { return false; } $approved = $comment->comment_approved; if ( null == $approved ) { return false; } elseif ( '1' == $approved ) { return 'approved'; } elseif ( '0' == $approved ) { return 'unapproved'; } elseif ( 'spam' === $approved ) { return 'spam'; } elseif ( 'trash' === $approved ) { return 'trash'; } else { return false; } }