最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to restrict user to see his comments only and admin can see everyone comments?

programmeradmin1浏览0评论

i was trying to achieve this how can i restrict user to see his comments only along with admin replies and admin can see everyone comments?

Any suggestion with code would be helpful as i am new to wordpress.

i was trying to achieve this how can i restrict user to see his comments only along with admin replies and admin can see everyone comments?

Any suggestion with code would be helpful as i am new to wordpress.

Share Improve this question edited Jun 30, 2011 at 10:27 scribu 13.2k38 silver badges49 bronze badges asked Jun 30, 2011 at 7:14 KiranKiran 92 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 2

Semi-Private Comments.just install this plugin.This plugin masks comments so that a user can only see comments written by himself or by an admin. Admins can see all comments.

put this code in wp-admin/edit-comments.php

function myplugin_get_comment_list_by_user($clauses) {
    if (is_admin()) {
        global $user_ID, $wpdb;
        $clauses['join'] = ", wp_posts";
        $clauses['where'] .= " AND wp_posts.post_author = ".$user_ID." AND wp_commentsment_post_ID = wp_posts.ID";
    };
    return $clauses;
};
// ensure that editors and admins can moderate everything
if(!current_user_can('edit_others_posts')) {
add_filter('comments_clauses', 'myplugin_get_comment_list_by_user');
}
发布评论

评论列表(0)

  1. 暂无评论