How To Show Authors Only Their Post Comments In WordPress Admin Area?

Default WordPress functionality shows all comments (in admin area) to all registered authors in your website. In this tutorial we will show you how you can restrict comment visibility in admin section so that authors can see only comments posted on their articles.

Login to your WordPress site, navigate to your admin area dashboard Appearance -> Editor and from the right dropdown menu select the theme active on your website.

Now from select functions.php file for editing and paste the following code:

function wps_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’, ‘wps_get_comment_list_by_user’);
}

Save the changes and that’s it.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.