For example, I have the following table:
| comment_ID | comment_author | comment_author_email
| -------------- | ---------------- | ---------------------- |
| 100 | Max | [email protected] |
| 101 | Max | [email protected] |
| 102 | Pierre | [email protected] |
| 103 | Max | [email protected] |
The result / output of my SQL request should be:
Max: 2
Max: 1 /* because of the different email */
Pierre: 1
My problem:
With the following SQL request, I can get the count of one specific user (the logged-in user):
global $wpdb;
$count = $wpdb->get_var('
SELECT COUNT(comment_author)
FROM ' . $wpdb->comments. '
WHERE comment_author_email = "' . get_comment_author_email() . '"');
echo $count . ' comments';
BUT: How to get the count of all comments per user (by name + email), instead of only the logged-in one?