Heb het zelf kunnen oplossen door het aanmaken van een nieuwe functie:
function avatar_sql( $comment_ID = 0) {
$author = apply_filters(‘comment_author’, get_comment_author( $comment_ID ) );
return $author;
}
En dan wordt dit de query:
$sql = “SELECT avatar FROM *tabelnaam* WHERE username = ‘” . avatar_sql() . “‘”;