我得到评论
$comments = get_comments(array(
'post_id'=>get_the_ID(),
'order'=>'ASC',
));
我$comment->comment_approved
在循环中检查时显示了评论。但我想向发送评论的人显示未经批准的评论。
我的解决方案是检查$_SERVER['HTTP_USER_AGENT'] == $comment->comment_agent
所有评论(是否批准)的循环,但是我不确定是否足够?还是必须检查其他值?
这是我发现的最佳解决方案:
// geting comments of post
$comments = get_comments(array(
'post_id'=>get_the_ID(),
'order'=>'ASC',
));
foreach($comments as $comment){
// if unapproved comment is not commented by this user continue...
if(!$comment->comment_approved && $_SERVER['HTTP_USER_AGENT'] != $comment->comment_agent){
continue;
}
// if unapproved comment is commented by this user show the message.
if(!$comment->comment_approved && $_SERVER['HTTP_USER_AGENT'] == $comment->comment_agent){
echo "Your comment is awaiting moderation";
}
// show the comment
echo $comment->comment_content . '<br>';
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句