Title: most comments by user
Last modified: August 19, 2016

---

# most comments by user

 *  [sinans11](https://wordpress.org/support/users/sinans11/)
 * (@sinans11)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/most-comments-by-user/)
 * Hi
    this code bellow shows most commenters on the blog but I wanted to know if
   it can be altered to show the amount of comments by the loged in user. So once
   a member loges in they can see how many comments they have left and a list of
   5 or 10 of the comments if possible. I’m ok with PHP but i’m new to wordpress
   so I don’t know the built in functions.
 * <?php
    global $wpdb; $where = ‘WHERE comment_approved = 1 AND user_id <> 0’; 
   $comment_counts = (array) $wpdb->get_results(“ SELECT user_id, COUNT( * ) AS 
   total FROM {$wpdb->comments} {$where} GROUP BY user_id “, object); foreach ( 
   $comment_counts as $count ) { $user = get_userdata($count->user_id); echo ‘User‘.
   $user->display_name . ‘ comment count is ‘ . $count->total . ‘ ‘; } ?>
 * [**Moderated–bump removed.** Please refrain from bumping as per [Forum Rules](http://wordpress.org/support/topic/68664?replies=6)]
 * [**Duplicate post deleted.** Please refrain from creating duplicate topics.]

The topic ‘most comments by user’ is closed to new replies.

## Tags

 * [Comments](https://wordpress.org/support/topic-tag/comments/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [sinans11](https://wordpress.org/support/users/sinans11/)
 * Last activity: [16 years, 5 months ago](https://wordpress.org/support/topic/most-comments-by-user/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
