Inspiration For Creative Minds
Home » Labs » How to display a user’s total comment count on WordPress  

Filed under Labs

Put below code to your template and it will display the total comment count of user.

	global $wpdb, $post, $current_user;
	$userId = $current_user->ID;
	$where = 'WHERE comment_approved = 1 AND user_id = ' . $userId ;
	$comment_count = $wpdb->get_var("SELECT COUNT( * ) AS total FROM {$wpdb->comments}{$where}");
	echo 'Comments: <strong>' . $comment_count . '</strong>';
It's only fair to share...Share on Google+Tweet about this on TwitterShare on Facebook

Posts you may like: