WordPress函数:comment_author_email 显示评论作者的 email

江河/ 2023年05月24日/ WordPress/ 浏览 912

函数原型:


comment_author_email( int|WP_Comment $comment_id )


显示作者的 email。


应注意保护电子邮件地址,并确保电子邮件收割机不会捕获您的评论者的电子邮件地址。大多数人认为他们的电子邮件地址不会以原始形式出现在网站上。这样做将使任何人,包括那些人们不想获得电子邮件地址并将其用于自己的手段的人,无论好坏。


参数说明:


$comment_id, WP_Comment 对象 或 评论 ID,默认当前评论。


函数源码:


function comment_author_email( $comment_id = 0 ) {
	$comment      = get_comment( $comment_id );
	$author_email = get_comment_author_email( $comment );

	echo apply_filters( 'author_email', $author_email, $comment->comment_ID );
}


包含钩子:


apply_filters( 'author_email', string $author_email, string $comment_id )


使用举例:


<a href="mailto:<?php comment_author_email(); ?>"><?php printf( __( 'Contact %s', 'textdomain' ), get_comment_author() ); ?></a>


发表评论

暂无评论,抢个沙发...

客服 工单