Title: Registered Users comment count
Last modified: August 19, 2016

---

# Registered Users comment count

 *  [junipingla](https://wordpress.org/support/users/junipingla/)
 * (@junipingla)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/registered-users-comment-count/)
 * I’ve been searching for so long for a plugin or hack or function that let’s me
   see how many comments a registered user has made.
 * I’m running a personal blog (plugin members only) and I would like to be able
   to easily have listed how many comments a user has made, perhaps listed in the
   users.php in the Admin panel.
 * Could anyone direct med to a solution??

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/registered-users-comment-count/#post-1075734)
 * This will get approved comment count for each registered user
 *     ```
       <?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 "<pre>"; print_r($count); echo "</pre>";
       //echo "<pre>"; print_r($user); echo "</pre>";
         echo 'User ' . $user->display_name . ' comment count is ' . $count->total . '
       ';
       }
       ?>
       ```
   
 * used wp-includes/comment.php ‘get_comment_count’ as example
 *  Thread Starter [junipingla](https://wordpress.org/support/users/junipingla/)
 * (@junipingla)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/registered-users-comment-count/#post-1075746)
 * Oh wow, thanks!! But where do I put this? Any advice is much appreciated!
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/registered-users-comment-count/#post-1075760)
 * I’d put it in an author template, but you mentioned your admin section and that’s
   not something I’m too comfortable doing ;(
 *  Thread Starter [junipingla](https://wordpress.org/support/users/junipingla/)
 * (@junipingla)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/registered-users-comment-count/#post-1075766)
 * OK Michael!
 * I would like to easily see which users that rarely or never comment, that’s why
   I would like to have it listed in the Userlist..
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/registered-users-comment-count/#post-1075769)
 * Wonder if something like Cimy User Extra Fields could be used and then make that
   code above into a function for the ‘extra field’?
 *  Thread Starter [junipingla](https://wordpress.org/support/users/junipingla/)
 * (@junipingla)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/registered-users-comment-count/#post-1075775)
 * I’ll look into it, it would be great if it worked.
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [16 years, 7 months ago](https://wordpress.org/support/topic/registered-users-comment-count/#post-1075995)
 * Has anyone had a chance to look into this?
 * I’d like that as well (actually I’d like to add fields to the users.php list,
   including that…)
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [16 years, 7 months ago](https://wordpress.org/support/topic/registered-users-comment-count/#post-1075996)
 * Okay, I found a way to incorporate this into a half-assed recently-registered
   plugin I’m working on, but I can’t update it since SVN is broken on my new machine.
   Heh.
 *  [ericmacknight](https://wordpress.org/support/users/ericmacknight/)
 * (@ericmacknight)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/registered-users-comment-count/#post-1076000)
 * MichaelH,
 * How can I modify your code above to generate a list that looks like this:
 * Alice (3)
    Bob (4) Carl (7) David (5)
 * Many thanks!
 * Eric

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Registered Users comment count’ is closed to new replies.

## Tags

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

 * 9 replies
 * 4 participants
 * Last reply from: [ericmacknight](https://wordpress.org/support/users/ericmacknight/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/registered-users-comment-count/#post-1076000)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
