Anyone got any ideas on this one?
Sorry, don’t know of a plugin. But the code needed is pretty straightforward:
<?php
global $wpdb;
$numcomments = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_author_email='$COMMENTER_EMAIL' AND comment_approved = '1'");
echo $numcomments;
?>
This tests on the comment author email address, and $COMMENTER_EMAIL would need to be replaced with what var you use to hold this value. If this is for registered users only, you might instead test on their user ID:
$numcomments = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE user_id='$USER_ID' AND comment_approved = '1'");
Again, change $USER_ID to the appropriate var in your code.
Thanks Kafkaesqui, I’ll look into making use of this code shortly. Very much appreciated. 🙂
Ryan,
Did you see this plugin? It will count user comments:
http://www.stilglog.com/wordpress-plugins/count-comments/
Ann
(@ryanwilliams)
19 years, 6 months ago
Hi,
I’d really like to have a profile page for commenters with some basic information as defined on their profile console. One thing I can’t work out how to display however is how many comments the person has posted; is there a way to do this using some kind of plugin?
I’ve earnestly searched for such a plugin but have been unable to find anything thus far. Any pointers would be muchos appreciated.