Sitewide Comment Tracking Revisited

Sitewide Comment Tracking Revisited

Update December 29, 2015: This post is part of the WPMU DEV Blog archive and contains information that is out-of-date, but we’re keeping it on the blog for posterity. For all the latest WordPress news and resources, check out the WPMU DEV Blog.

Useful for tracking comments by community users with output visible in:Dashboard–>Comments–>My Comments.

MY_COMMENTS_TRACKED = `if (count($LatestCommentsList) > MY_COMMENTS_TRACKED) { unset($LatestCommentsList[0]); …}` during a comment save a blog_id, post_id pair is entered into usermeta->LatestComments, the total counted and when the array exceeds limit, the oldest pair is deleted = 100

MY_POSTS_APAGE = more posts per page = increased work for CPU = 10

MY_COMMENTS_APOST = more comments per post = increased work for CPU = 1

Performance notes: tested on a small WPMU install(>200 blogs). I have not seen how this version performs “maxed out” on my own install yet. I do not know how this plugin performs in a large install. An array of “Blog_id, post_id” pairs are stored in usermeta->LatestComments to a defined maximum, called then sliced by page number, looped to retrieve posts, then each post looped to retrieve comments – “My Comments” and “Other comments”. The bottom of the My Comments page has a numqueries count, FYI(if SiteAdmin). Redefining the MY_POSTS_APAGE constant can throttle the page.

Known Bugs: redefining the MY_COMMENTS_TRACKED constant to a lower limit after users have “maxed out” the previous limit will only unset one comment after each comment submit(“update_usermeta(…)”) thereafter. Such users will continue to exceed MY_COMMENTS_TRACKED Limit until they “dismiss” enough comments to be below the newly defined limit.

Install Notes: drop in mu-plugin, monitor performace/cpu load as “usermeta->LatestComments” data fills with each user comment submitted to defined maximum(MY_COMMENTS_TRACKED). I have not tested this revised version under heavy load. Happy testing!