评论者在wordpress中只能看到他的评论 [英] Commenter should see only his comments in wordpress

查看:120
本文介绍了评论者在wordpress中只能看到他的评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个研究站点,所有参与者都将登录以使用该站点。
我想让这些参与者只能看到他们自己的评论,所以其他用户的评论将被隐藏。

I'm building a site for a research and my participants will be all logged in to use the site. I would like to make these participants able to see only their own comments, so other users' comments will be hidden.

我正在使用这些评论。带有以下简单代码的php文件:

I'm using the comments.php file with, among other things, this simple code:

<?php if ( have_comments() ) : ?>

      <ol class="commentlist">
          <?php wp_list_comments(); ?>
      </ol>

      <?php if ( ! comments_open() ) : ?>
          <p class="no-comments">Comments are closed</p>
      <?php endif; ?>

<?php endif; ?>

我需要在此代码周围放置哪些内容,以过滤注释并仅向所有者显示?
谢谢。

What do I need to place around this code to filter the comments and show them only to their owners? Thanks.

推荐答案

您需要编辑评论模板并结合使用

You need to edit the comments template and use a combination of this

get_comment(get_comment_ID())->user_id;

返回被评论者的用户ID,并将其与当前用户进行比较

which returns the user id of whoever commented, and compare it to the current user with

get_current_user_id();

如果未注册评论者或当前用户未登录,则都返回0,

Both return 0 if the commenter wasn't registered or if the current user isn't logged in, respectively.

这篇关于评论者在wordpress中只能看到他的评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆