Title: Inaccurate Comments Count
Last modified: August 21, 2016

---

# Inaccurate Comments Count

 *  [Swampy](https://wordpress.org/support/users/johnrichter/)
 * (@johnrichter)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/inaccurate-comments-count/)
 * I understand (I think) the caveats overview in the link provided from the plugin,
   i.e. [http://wpusersplugin.com/1822/comment-totals-by-authors/](http://wpusersplugin.com/1822/comment-totals-by-authors/).
 * I have a fairly simple site, with three users who have provided comments (and
   replies). The total number is 97 in the Comments area (not sure how many of these
   are ‘replies’. Akismet reporting shows 39, 38, and 20 “approved” items for Users
   1 – 3, so that aligns.
 * As well, WP Stats page (under the dashboard tab) shows:
    User 1(39) User 2(38)
   User 3(20)
 * So that ties with total and Akismet.
 * I set-up a report reporting both Comments count and Replies count and got the
   following (comments / replies):
 * User 1 29 / 3
    User 2 38 / 2 User 3 20 / 3
 * First item is a question, does the comments count (essentially) include replies?
 * Presuming the answer to this is ‘Yes”, then users 2 and 3 have counts that align.
   However User 1 is showing 10 fewer than he should.
 * Any thoughts on what might be causeing this reconciliation problem or how I might
   debug this?
 * [https://wordpress.org/plugins/amr-users/](https://wordpress.org/plugins/amr-users/)

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

 *  Thread Starter [Swampy](https://wordpress.org/support/users/johnrichter/)
 * (@johnrichter)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/inaccurate-comments-count/#post-5076318)
 * Sorry, follow-up on my own post. Clearly Comments and Replies are different data
   types, and I now see that the Reply count (for each of three users) matches up.
   Hence, only issue is that the Comments Count for User 1 is off by 10.
 *  Plugin Author [anmari](https://wordpress.org/support/users/anmari/)
 * (@anmari)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/inaccurate-comments-count/#post-5076407)
 * Hi – had a quick look and one reason might be :
    amr-users queries comments made
   by users (not by non-users) AND if an email address first made comments as a 
   non-user than became a user, WP does NOT go back and update it’s comment history.(
   It stores userid in the comments table).
 * So amr-users will NOT include comments without a userid (ie userid=0) and will
   include comments even if to a post that no longer exists and/or has changed status.(
   Looking at user activity)
 * wp-stats queries and groups by email (doesn’t care about userid).
 * There are also other differences – wpstats is ‘post oriented’, so if a post changes
   status this might also cause a difference. where wp-stats might exclude those
   comments.
 * See:
 * amr-users:
 * > `SELECT user_id, comment_author_email, count(1) as \"comment_count\" FROM $
   > wpdb->comments WHERE $approved AND user_id > 0 GROUP BY user_id, comment_author_email;`
 * wpstats:
 * > `SELECT comment_author, COUNT(comment_ID) AS ‘comment_total’ FROM $wpdb->comments
   > INNER JOIN $wpdb->posts ON $wpdb->comments.comment_post_ID = $wpdb->posts.ID
   > WHERE comment_approved = ‘1’ AND comment_type = ” “
   >  .”AND post_date < ‘”.current_time(‘
   > mysql’).”‘ “ .”AND post_status = ‘publish’ AND post_password = ” GROUP BY comment_author
   > ORDER BY comment_total DESC $limit_sql”)`
 *  Thread Starter [Swampy](https://wordpress.org/support/users/johnrichter/)
 * (@johnrichter)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/inaccurate-comments-count/#post-5076441)
 * Anmari, many thanks for this guidance. Useful possibilities. I’ve just (sort 
   of accidentally) hit on a lead to sorting this out / understanding what might
   be going on — perhaps need to directly clean some things up in database, though
   concerned about this behavior going forward for other users . . . so here’s what
   I’ve figured out since my first post.
 * This particular user changed his email in the course of matters, from a .org 
   extension to a .com extension.
 * He’s written 39 total comments, they are all showing as User ID = 10, the most
   recent 10 of which are showing his email as .com, and these are (apparently) 
   not being counted. If I simply go to comment (and remember they are all User 
   ID = 10, not 0s) and change email address for author of comment (back) to the.
   org, this then shows up in the count. So there definitely seems to be some linkage.
 * It seems like some focus / use of the email address needing to match some sort
   of ‘original email’ address sitting in the comments table for purposes of this
   counting (or it uses the first / earliest comment to instance of email address)?
 * Is that consistent with behavior you might expect and/or is there something in
   this that should be amended perhaps in the code? I’m not a PHP guy, but is the
   second argument in the GROUP BY statement, by comment_author_email appropriate?
   Shouldn’t we simply be getting counts for a given user_ID, which should be unique,
   not a ‘shared persona’, if that makes sense?
 *  Thread Starter [Swampy](https://wordpress.org/support/users/johnrichter/)
 * (@johnrichter)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/inaccurate-comments-count/#post-5076444)
 * Just as a test / follow-up, I hacked out the second argument of the GROUP BY 
   element, so just groups by User ID, and this seems to fix count problem (in my
   case) — on first blush, not tested much yet. Curious as to rationale for the 
   secondary grouping and where I’m likely to hit problems with that hack.
 * John
 * P.S. btw, I’m completely clueless on WordPress, PHP, etc (set up my first website
   about 8 weeks ago), but how in God’s name to you developers set yourself up to
   find code strings across multiple files — I mean brutal (for me) in this instance
   to find that your quoted statement was in your ameta-list.php file. How do you
   guys do this properly — I can’t seem to find any plugins for ‘search across multiple
   files’ in the Admin area.
 *  Plugin Author [anmari](https://wordpress.org/support/users/anmari/)
 * (@anmari)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/inaccurate-comments-count/#post-5076521)
 * you may have a point re just using userid.
 * re working tools:
    always always always run a local server (working remotely 
   is difficult) – see WAMP and use notepad++ on windows (there are others for mac
   but notepad++ is best)
 *  Thread Starter [Swampy](https://wordpress.org/support/users/johnrichter/)
 * (@johnrichter)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/inaccurate-comments-count/#post-5076522)
 * many thanks for that. I’ll advise re: I see any issues that might be connected
   to my hack of that one statement. Perhaps rationale was to sub-deivide the UserID
   = 0 entries by email address? Not sure if there would be one, though, for unregistered
   users. If the case, perhaps a conditional on this one circumstance — God knows.
 * Excellent support and excellent plugin. Very helpful in upgrading user management
   short of moving to a CRM system, which can be a bit overblown for some purposes.

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

The topic ‘Inaccurate Comments Count’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/amr-users_f6f6f4.svg)
 * [amr users](https://wordpress.org/plugins/amr-users/)
 * [Support Threads](https://wordpress.org/support/plugin/amr-users/)
 * [Active Topics](https://wordpress.org/support/plugin/amr-users/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amr-users/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amr-users/reviews/)

## Tags

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

 * 6 replies
 * 2 participants
 * Last reply from: [Swampy](https://wordpress.org/support/users/johnrichter/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/inaccurate-comments-count/#post-5076522)
 * Status: not resolved