Last active
June 30, 2020 19:35
-
-
Save jonathanstegall/d46ddffbf0199fca402bd07e5c3a1184 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT u.ID, u.user_email, count(distinct ifnull(c.comment_ID, 0)) as count, | |
| ( | |
| SELECT GROUP_CONCAT( m.meta_value ) | |
| FROM wp_usermeta m | |
| WHERE m.meta_key = 'member_level' AND m.user_id = u.ID AND m.meta_value != 'Non-member' | |
| ) as member_level | |
| FROM wp_users u | |
| JOIN wp_comments c ON u.ID = c.user_id | |
| WHERE comment_approved = 1 AND comment_type IN ("comment", "") AND c.user_id <> 0 | |
| GROUP BY u.ID | |
| ORDER BY count DESC |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use this to also check if they've already got a setting to load all the comments. This puts them to the bottom if they do have that field, no matter how many comments they've got:
Note: for this purpose, we don't care about the member level so it's not included.