Deleting posts by banned users with < 3 posts?

AI-generated summary

Deleting posts by banned users with < 3 posts

The discussion revolves around finding and deleting posts from banned users who have made less than three posts. kirupa explains that during the migration from vBulletin to Discourse, posts from banned users became visible, and they want to bulk delete these posts.

sam suggests using a Data Explorer query to solve the problem. michebs provides a query to find banned users with less than three posts:

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

Additionally, michebs mentions using the API (/admin/users/{id}.json) to delete the users. kirupa thanks michebs and sam for their help.

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

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

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.

Thanks a lot Michelle, Sam :slight_smile: