wp_unspam_comment

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

WordPress Version: 6.1

/**
 * Removes a comment from the Spam.
 *
 * @since 2.9.0
 *
 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
 * @return bool True on success, false on failure.
 */
function wp_unspam_comment($comment_id)
{
    $comment = get_comment($comment_id);
    if (!$comment) {
        return false;
    }
    /**
     * Fires immediately before a comment is unmarked as Spam.
     *
     * @since 2.9.0
     * @since 4.9.0 Added the `$comment` parameter.
     *
     * @param string     $comment_id The comment ID as a numeric string.
     * @param WP_Comment $comment    The comment to be unmarked as spam.
     */
    do_action('unspam_comment', $comment->comment_ID, $comment);
    $status = (string) get_comment_meta($comment->comment_ID, '_wp_trash_meta_status', true);
    if (empty($status)) {
        $status = '0';
    }
    if (wp_set_comment_status($comment, $status)) {
        delete_comment_meta($comment->comment_ID, '_wp_trash_meta_status');
        delete_comment_meta($comment->comment_ID, '_wp_trash_meta_time');
        /**
         * Fires immediately after a comment is unmarked as Spam.
         *
         * @since 2.9.0
         * @since 4.9.0 Added the `$comment` parameter.
         *
         * @param string     $comment_id The comment ID as a numeric string.
         * @param WP_Comment $comment    The comment unmarked as spam.
         */
        do_action('unspammed_comment', $comment->comment_ID, $comment);
        return true;
    }
    return false;
}

WordPress Version: 5.9

/**
 * Removes a comment from the Spam
 *
 * @since 2.9.0
 *
 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
 * @return bool True on success, false on failure.
 */
function wp_unspam_comment($comment_id)
{
    $comment = get_comment($comment_id);
    if (!$comment) {
        return false;
    }
    /**
     * Fires immediately before a comment is unmarked as Spam.
     *
     * @since 2.9.0
     * @since 4.9.0 Added the `$comment` parameter.
     *
     * @param string     $comment_id The comment ID as a numeric string.
     * @param WP_Comment $comment    The comment to be unmarked as spam.
     */
    do_action('unspam_comment', $comment->comment_ID, $comment);
    $status = (string) get_comment_meta($comment->comment_ID, '_wp_trash_meta_status', true);
    if (empty($status)) {
        $status = '0';
    }
    if (wp_set_comment_status($comment, $status)) {
        delete_comment_meta($comment->comment_ID, '_wp_trash_meta_status');
        delete_comment_meta($comment->comment_ID, '_wp_trash_meta_time');
        /**
         * Fires immediately after a comment is unmarked as Spam.
         *
         * @since 2.9.0
         * @since 4.9.0 Added the `$comment` parameter.
         *
         * @param string     $comment_id The comment ID as a numeric string.
         * @param WP_Comment $comment    The comment unmarked as spam.
         */
        do_action('unspammed_comment', $comment->comment_ID, $comment);
        return true;
    }
    return false;
}

WordPress Version: 4.9

/**
 * Removes a comment from the Spam
 *
 * @since 2.9.0
 *
 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
 * @return bool True on success, false on failure.
 */
function wp_unspam_comment($comment_id)
{
    $comment = get_comment($comment_id);
    if (!$comment) {
        return false;
    }
    /**
     * Fires immediately before a comment is unmarked as Spam.
     *
     * @since 2.9.0
     * @since 4.9.0 Added the `$comment` parameter.
     *
     * @param int        $comment_id The comment ID.
     * @param WP_Comment $comment    The comment to be unmarked as spam.
     */
    do_action('unspam_comment', $comment->comment_ID, $comment);
    $status = (string) get_comment_meta($comment->comment_ID, '_wp_trash_meta_status', true);
    if (empty($status)) {
        $status = '0';
    }
    if (wp_set_comment_status($comment, $status)) {
        delete_comment_meta($comment->comment_ID, '_wp_trash_meta_status');
        delete_comment_meta($comment->comment_ID, '_wp_trash_meta_time');
        /**
         * Fires immediately after a comment is unmarked as Spam.
         *
         * @since 2.9.0
         * @since 4.9.0 Added the `$comment` parameter.
         *
         * @param int        $comment_id The comment ID.
         * @param WP_Comment $comment    The comment unmarked as spam.
         */
        do_action('unspammed_comment', $comment->comment_ID, $comment);
        return true;
    }
    return false;
}

WordPress Version: 4.4

/**
 * Removes a comment from the Spam
 *
 * @since 2.9.0
 *
 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
 * @return bool True on success, false on failure.
 */
function wp_unspam_comment($comment_id)
{
    $comment = get_comment($comment_id);
    if (!$comment) {
        return false;
    }
    /**
     * Fires immediately before a comment is unmarked as Spam.
     *
     * @since 2.9.0
     *
     * @param int $comment_id The comment ID.
     */
    do_action('unspam_comment', $comment->comment_ID);
    $status = (string) get_comment_meta($comment->comment_ID, '_wp_trash_meta_status', true);
    if (empty($status)) {
        $status = '0';
    }
    if (wp_set_comment_status($comment, $status)) {
        delete_comment_meta($comment->comment_ID, '_wp_trash_meta_status');
        delete_comment_meta($comment->comment_ID, '_wp_trash_meta_time');
        /**
         * Fires immediately after a comment is unmarked as Spam.
         *
         * @since 2.9.0
         *
         * @param int $comment_id The comment ID.
         */
        do_action('unspammed_comment', $comment->comment_ID);
        return true;
    }
    return false;
}

WordPress Version: 3.9

/**
 * Removes a comment from the Spam
 *
 * @since 2.9.0
 *
 * @param int $comment_id Comment ID.
 * @return bool True on success, false on failure.
 */
function wp_unspam_comment($comment_id)
{
    if (!(int) $comment_id) {
        return false;
    }
    /**
     * Fires immediately before a comment is unmarked as Spam.
     *
     * @since 2.9.0
     *
     * @param int $comment_id The comment ID.
     */
    do_action('unspam_comment', $comment_id);
    $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);
    if (empty($status)) {
        $status = '0';
    }
    if (wp_set_comment_status($comment_id, $status)) {
        delete_comment_meta($comment_id, '_wp_trash_meta_status');
        /**
         * Fires immediately after a comment is unmarked as Spam.
         *
         * @since 2.9.0
         *
         * @param int $comment_id The comment ID.
         */
        do_action('unspammed_comment', $comment_id);
        return true;
    }
    return false;
}

WordPress Version: 3.8

/**
 * Removes a comment from the Spam
 *
 * @since 2.9.0
 * @uses do_action() on 'unspam_comment' before unspamming
 * @uses do_action() on 'unspammed_comment' after unspamming
 *
 * @param int $comment_id Comment ID.
 * @return bool True on success, false on failure.
 */
function wp_unspam_comment($comment_id)
{
    if (!(int) $comment_id) {
        return false;
    }
    /**
     * Fires immediately before a comment is unmarked as Spam.
     *
     * @since 2.9.0
     *
     * @param int $comment_id The comment ID.
     */
    do_action('unspam_comment', $comment_id);
    $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);
    if (empty($status)) {
        $status = '0';
    }
    if (wp_set_comment_status($comment_id, $status)) {
        delete_comment_meta($comment_id, '_wp_trash_meta_status');
        /**
         * Fires immediately after a comment is unmarked as Spam.
         *
         * @since 2.9.0
         *
         * @param int $comment_id The comment ID.
         */
        do_action('unspammed_comment', $comment_id);
        return true;
    }
    return false;
}

WordPress Version: 3.7

/**
 * Removes a comment from the Spam
 *
 * @since 2.9.0
 * @uses do_action() on 'unspam_comment' before unspamming
 * @uses do_action() on 'unspammed_comment' after unspamming
 *
 * @param int $comment_id Comment ID.
 * @return bool True on success, false on failure.
 */
function wp_unspam_comment($comment_id)
{
    if (!(int) $comment_id) {
        return false;
    }
    do_action('unspam_comment', $comment_id);
    $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);
    if (empty($status)) {
        $status = '0';
    }
    if (wp_set_comment_status($comment_id, $status)) {
        delete_comment_meta($comment_id, '_wp_trash_meta_status');
        do_action('unspammed_comment', $comment_id);
        return true;
    }
    return false;
}