Trying to filter all my comments by a specific user role. In this case, the user role is called group1. This will return all comments only when I remove WHERE m.meta_key = 'wp_capabilities' AND m.meta_value = 'group1'
from the query below.

$query = $wpdb->prepare( "SELECT *
                    FROM $wpdb->comments c
                    LEFT JOIN $wpdb->commentmeta cm ON c.comment_ID = cm.comment_id
                    LEFT JOIN $wpdb->users u ON c.user_id = u.ID
                    LEFT JOIN $wpdb->usermeta m ON m.user_id = u.ID
                    WHERE c.comment_post_ID = %s
                    AND c.comment_approved = 1
                    WHERE m.meta_key = 'wp_capabilities'
                    AND m.meta_value = 'group1'
                    ORDER BY c.comment_ID $comment_order

Read more here: Filter wordpress comments by user role


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: