How to display only logged in user’s post comments in comments area

i had been looking for the code where logged in users will be able to see post of his own only i have managed to make simple function that we can use for the same the function snippet has to be included in functions .php file in the theme folder which you are using

function my_plugin_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;

}

// Ensure that editors and admins can moderate all comments

if(!current_user_can('edit_others_posts')) 

{

 add_filter('comments_clauses', 'my_plugin_get_comment_list_by_user');

}

Thanks
NIkhil Joshi

Leave a Comment