• 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)
  • 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

    (@junipingla)

    Oh wow, thanks!! But where do I put this? Any advice is much appreciated!

    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

    (@junipingla)

    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..

    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

    (@junipingla)

    I’ll look into it, it would be great if it worked.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    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)

    (@ipstenu)

    ?????? Advisor and Activist

    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

    (@ericmacknight)

    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.