A WordPress-centric search engine for devs and theme authors



wp_get_comment_status ›

Since1.0.0
Deprecatedn/a
wp_get_comment_status ( $comment_id )
Parameters:
  • (int|WP_Comment) $comment_id Comment ID or WP_Comment object
    Required: Yes
Returns:
  • (false|string) Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
Defined at:
Codex:

The status of a comment by ID.



Source

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;
	}
}