把下面的代码复制到您的主题下面的Functions.php中。

/*只能查看自己的文章评论*/
function wpdx_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_comments.comment_post_ID = wp_posts.ID”;
};
return $clauses;
};
if(!current_user_can(‘edit_others_posts’)) {
add_filter(‘comments_clauses’, ‘wpdx_get_comment_list_by_user’);
}

/*只能查看自己发布的文章*/
function wpjam_parse_query_useronly( $wp_query ) {
if ( strpos( $_SERVER[ ‘REQUEST_URI’ ], ‘/wp-admin/edit.php’ ) !== false ) {
if ( !current_user_can( ‘add_user’ ) ) {
global $current_user;
$wp_query->set( ‘author’, $current_user->id );
}
}
}
add_filter(‘parse_query’, ‘wpjam_parse_query_useronly’ );


寒林

www.3code.cn 专注WordPress企业主题