首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >限制评论wordpress

限制评论wordpress
EN

Stack Overflow用户
提问于 2018-09-21 20:36:33
回答 1查看 25关注 0票数 0

我已经修改了我的代码。现在,用户可以看到他们的评论,管理员可以看到所有用户的评论。但是用户仍然不能看到管理员.They的评论,只能看到他们的评论..我该如何实现这一点..

代码语言:javascript
复制
<?php

/**
 * Used as a callback by wp_list_comments() for displaying the comments.
 */
function _s_comment( $comment, $args, $depth ) 
  {
    $GLOBALS['comment'] = $comment;
    $current_user_id = get_current_user_id();
    $current_user = wp_get_current_user(); 
    if ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) : ?>
      <li id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
      <div class="comment-body">
      </div>
      <?php elseif ( $current_user_id == $comment->user_id || ($current_user->roles[0] == 'administrator' ) : ?> 

       <li id="comment-<?php comment_ID(); ?>"

EN

回答 1

Stack Overflow用户

发布于 2018-09-21 21:21:24

好的,我已经找到解决方案了。

if( post作者$comment-> $current_user_id _id || $post->post_author == $comment->user_id )

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52443958

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档