W3cubDocs

/WordPress

wp_get_unapproved_comment_author_email()

Get unapproved comment author’s email.

Description

Used to allow the commenter to see their pending comment.

Return

(string) The unapproved comment author's email (when supplied).

Source

File: wp-includes/comment.php

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

Changelog

Version Description
5.1.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_get_unapproved_comment_author_email