A few years ago, we moved to discourse from vbulletin. As part of this migration, a lot of banned users were imported as well. That’s not the problem. The posts they created ended up showing up as visible in discourse. Almost all of these banned users created 1 or 2 posts before being discovered and banned, but whatever setting hid their posts in vbulletin ended up causing those posts to be shown in discourse. These posts being visible is the problem.
Is there a way to find all posts from banned users who have made less than three posts and bulk delete them?
You can find all banned users with <3 posts using the following Data Explorer query:
SELECT p.user_id, COUNT(p.id) AS qtt_posts
FROM posts p
INNER JOIN users u ON u.id = p.user_id
WHERE suspended_till NOTNULL
GROUP BY user_id
HAVING COUNT(p.id) < 3
To delete the users you can use the API: /admin/users/{id}.json, you can see the documentation here.