Deleting posts by banned users with < 3 posts?

Hi everyone!

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?

Thanks,
Kirupa

2 Likes

Yeah a data explorer query can do that. Hopefully someone from the community can help.

3 Likes

Hi Kirupa,

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.

4 Likes

Thanks a lot Michelle, Sam :slight_smile:

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.