wp_get_comment_status

The timeline below displays how wordpress function wp_get_comment_status has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Retrieves the status of a comment by comment ID.
 *
 * @since 1.0.0
 *
 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object
 * @return string|false Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
 */
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;
    }
}

WordPress Version: 5.5

/**
 * The status of a comment by ID.
 *
 * @since 1.0.0
 *
 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object
 * @return string|false Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
 */
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;
    }
}

WordPress Version: 5.4

/**
 * The status of a comment by ID.
 *
 * @since 1.0.0
 *
 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object
 * @return string|false Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
 */
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;
    }
}

WordPress Version: 4.4

/**
 * The status of a comment by ID.
 *
 * @since 1.0.0
 *
 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object
 * @return false|string Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
 */
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;
    }
}

WordPress Version: 4.1

/**
 * The status of a comment by ID.
 *
 * @since 1.0.0
 *
 * @param int $comment_id Comment ID
 * @return false|string Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
 */
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;
    }
}

WordPress Version: 3.7

/**
 * The status of a comment by ID.
 *
 * @since 1.0.0
 *
 * @param int $comment_id Comment ID
 * @return string|bool Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
 */
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;
    }
}