
WordPress主题开发入门基础教程
wp_get_unapproved_comment_author_email ( No parameters )
wp_get_unapproved_comment_author_email: 这个函数检索与未批准的评论相关的电子邮件地址。它需要一个参数:评论ID: 该函数检查该评论是否未被批准,如果未被批准,则返回与该评论相关的电子邮件地址。
获得未批准的评论作者的电子邮件。
用来让评论者看到他们的待定评论。
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; }