How to Remove and Moderate Spam Entries and Users from Flarum Database
Managing a Flarum forum often involves handling spam posts and users. These unwanted entries can crowd your database and potentially impact performance. This guide provides steps to remove spam entries and their corresponding users, while also setting up a manual approval process for new posts.
⚠️ Warning: Before you proceed, make sure to take a full backup of your database. The SQL commands will permanently delete data.
Required Tables:
users
posts
discussions
SQL Script for Removal:
`-- Create a temporary table to store affected User-IDs
CREATE TEMPORARY TABLE temp_spam_users (id INT(10) UNSIGNED);
-- Insert User-IDs of spam accounts into the temporary table
INSERT INTO temp_spam_users(id)
SELECT DISTINCT user_id FROM posts WHERE is_private = 1;
-- Delete discussions created by spam users
DELETE FROM discussions WHERE user_id IN (SELECT id FROM temp_spam_users);
-- Delete posts from spam users
DELETE FROM posts WHERE user_id IN (SELECT id FROM temp_spam_users);
-- Delete the spam users themselves
DELETE FROM users WHERE id IN (SELECT id FROM temp_spam_users);
-- Drop the temporary table
DROP TEMPORARY TABLE temp_spam_users;
`
Steps to Execute:
- manual approval
- Backup your database.
- Run the SQL script for removal.
Verify if the spam entries and users have been removed and new posts require manual approval.
By following these steps, you'll not only delete existing spam but also require new posts to be manually approved, giving you more control over your forum content.
Again, ensure you backup your database before running any of these commands.
Good luck in keeping your forum spam-free and well-moderated! 🍀