most comments by user
-
Hi
this code bellow shows most commenters on the blog but I wanted to know if it can be altered to show the amount of comments by the loged in user. So once a member loges in they can see how many comments they have left and a list of 5 or 10 of the comments if possible. I’m ok with PHP but i’m new to wordpress so I don’t know the built in functions.<?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 ‘User ‘ . $user->display_name . ‘ comment count is ‘ . $count->total . ‘
‘;
}
?>[Moderated–bump removed. Please refrain from bumping as per Forum Rules]
[Duplicate post deleted. Please refrain from creating duplicate topics.]
- The topic ‘most comments by user’ is closed to new replies.