wp_get_unapproved_comment_author_email

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

WordPress Version: 6.1

/**
 * Gets unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 * @since 5.7.0 The window within which the author email for an unapproved comment
 *              can be retrieved was extended to 10 minutes.
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            // The comment will only be viewable by the comment author for 10 minutes.
            $comment_preview_expires = strtotime($comment->comment_date_gmt . '+10 minutes');
            if (time() < $comment_preview_expires) {
                $commenter_email = $comment->comment_author_email;
            }
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: 5.7

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 * @since 5.7.0 The window within which the author email for an unapproved comment
 *              can be retrieved was extended to 10 minutes.
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            // The comment will only be viewable by the comment author for 10 minutes.
            $comment_preview_expires = strtotime($comment->comment_date_gmt . '+10 minutes');
            if (time() < $comment_preview_expires) {
                $commenter_email = $comment->comment_author_email;
            }
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: .10

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            // The comment will only be viewable by the comment author for 1 minute.
            $comment_preview_expires = strtotime($comment->comment_date_gmt . '+1 minute');
            if (time() < $comment_preview_expires) {
                $commenter_email = $comment->comment_author_email;
            }
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: 5.4

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            $commenter_email = $comment->comment_author_email;
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: 3.4

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            // The comment will only be viewable by the comment author for 1 minute.
            $comment_preview_expires = strtotime($comment->comment_date_gmt . '+1 minute');
            if (time() < $comment_preview_expires) {
                $commenter_email = $comment->comment_author_email;
            }
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: 3.2

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            $commenter_email = $comment->comment_author_email;
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: .10

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            // The comment will only be viewable by the comment author for 1 minute.
            $comment_preview_expires = strtotime($comment->comment_date_gmt . '+1 minute');
            if (time() < $comment_preview_expires) {
                $commenter_email = $comment->comment_author_email;
            }
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: 5.3

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            $commenter_email = $comment->comment_author_email;
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: 2.7

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            // The comment will only be viewable by the comment author for 1 minute.
            $comment_preview_expires = strtotime($comment->comment_date_gmt . '+1 minute');
            if (time() < $comment_preview_expires) {
                $commenter_email = $comment->comment_author_email;
            }
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: 2.3

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            $commenter_email = $comment->comment_author_email;
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: .20

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            // The comment will only be viewable by the comment author for 1 minute.
            $comment_preview_expires = strtotime($comment->comment_date_gmt . '+1 minute');
            if (time() < $comment_preview_expires) {
                $commenter_email = $comment->comment_author_email;
            }
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: 2.2

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            $commenter_email = $comment->comment_author_email;
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: .10

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            // The comment will only be viewable by the comment author for 1 minute.
            $comment_preview_expires = strtotime($comment->comment_date_gmt . '+1 minute');
            if (time() < $comment_preview_expires) {
                $commenter_email = $comment->comment_author_email;
            }
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: 5.2

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            $commenter_email = $comment->comment_author_email;
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: 1.6

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            // The comment will only be viewable by the comment author for 1 minute.
            $comment_preview_expires = strtotime($comment->comment_date_gmt . '+1 minute');
            if (time() < $comment_preview_expires) {
                $commenter_email = $comment->comment_author_email;
            }
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: 1.2

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            $commenter_email = $comment->comment_author_email;
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: .10

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            // The comment will only be viewable by the comment author for 1 minute.
            $comment_preview_expires = strtotime($comment->comment_date_gmt . '+1 minute');
            if (time() < $comment_preview_expires) {
                $commenter_email = $comment->comment_author_email;
            }
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}

WordPress Version: 5.1

/**
 * Get unapproved comment author's email.
 *
 * Used to allow the commenter to see their pending comment.
 *
 * @since 5.1.0
 *
 * @return string The unapproved comment author's email (when supplied).
 */
function wp_get_unapproved_comment_author_email()
{
    $commenter_email = '';
    if (!empty($_GET['unapproved']) && !empty($_GET['moderation-hash'])) {
        $comment_id = (int) $_GET['unapproved'];
        $comment = get_comment($comment_id);
        if ($comment && hash_equals($_GET['moderation-hash'], wp_hash($comment->comment_date_gmt))) {
            $commenter_email = $comment->comment_author_email;
        }
    }
    if (!$commenter_email) {
        $commenter = wp_get_current_commenter();
        $commenter_email = $commenter['comment_author_email'];
    }
    return $commenter_email;
}