Smart Spam Cleaner

Description

Smart Spam Cleaner provides an efficient way to remove spam users, posts, and comments from your WordPress site. It uses background processing via WordPress cron jobs to handle large datasets without impacting your site’s performance.

Key Features

  • Dynamic Filtering – Configure your own spam keywords and email domains
  • Advanced Conditions – Use AND/OR logic to combine keyword and domain filters
  • Include/Exclude Domains – Specify which email domains to target or protect
  • Flexible Post Handling – Choose between moving posts to trash or permanent deletion
  • Background Processing – Uses WordPress cron jobs for non-blocking cleanup operations
  • Batch Processing – Processes users and posts in small batches to avoid server overload
  • Smart Detection – Identifies spam users based on customizable patterns
  • Detailed Logging – Comprehensive logging of all cleanup activities
  • Modern UI – Beautiful, responsive admin interface with progress tracking
  • Security – Built-in security measures including nonce verification and capability checks
  • Protect List – Emails and user IDs that are never deleted
  • Dry Run – Full batch walk that logs matches without deleting
  • Configurable Roles – Choose which roles to scan. Defaults to subscribers. Administrators are never deleted
  • Post Types and Statuses – Scan posts plus selected public types, including drafts, pending, and private when you turn those on
  • Comment Cleanup – Trash or delete comments that match the post keyword list
  • Preview – Sample matching users, posts, and comments before a cleanup
  • Cancel – Stop an in-progress cleanup between batches

What Gets Deleted

Users:
The plugin uses your configured filters to determine which users to delete:

  • Keyword Matching – Users with spam keywords in email, username, or display name
  • Domain Filtering – Users with email domains in your include list (or all domains except exclude list)
  • Condition Logic:
    • OR: Delete if user matches ANY keyword OR domain filter
    • AND: Delete if user matches ALL keyword AND domain filters
  • Only affects the roles you select. The default is subscriber
  • Never deletes users who have the administrator role

Posts:

  • Posts of the selected types and statuses that contain spam keywords in the title or content
  • Defaults to published posts
  • Uses your configured post keywords list
  • Deletion Mode (also used for comments):
    • Move to Trash: Items are moved to WordPress trash (recoverable)
    • Permanent Delete: Items are permanently deleted (irreversible)

Comments:

  • Approved and held comments whose content, author name, or author email matches the post keyword list
  • Spam and trash comments are left alone
  • Comments from protected emails or user IDs are skipped
  • Uses the same trash or permanent-delete mode as posts

Use Cases

  • Clean up spam user registrations
  • Remove bot-generated users
  • Delete users from specific spam domains
  • Clean up casino/gambling spam posts
  • Bulk delete spam comments authors
  • Protect legitimate users while removing spam

Safety Features

  • Defaults to the subscriber role and never deletes administrators
  • Protect list skips listed emails and user IDs even when filters match, including comment authors
  • Dry run and preview do not delete anything
  • Cancel stops the next batch; items already deleted stay deleted
  • Requires administrator privileges to run
  • Includes confirmation dialogs
  • Provides detailed logging for transparency
  • Always backup your database before running cleanup operations

Configuration

Default Settings

  • Batch Size – 500 items per batch
  • User Keywords – btc, binance, crypto, telegram, usd, tinkoff, money, trading, wallet, forex, meta, xrp, airdrop, bam, bet, eur, rub, invest, usdt, euro
  • User Domains:
    • Include: (empty – all domains)
    • Exclude: gmail.com
  • User Condition – OR
  • User Roles – subscriber
  • Post Keywords – casino, gambling, slots, bet, poker, blackjack, win money, jackpot, spin, roulette, wager, baccarat
  • Post Types – post
  • Post Statuses – publish
  • Content Deletion Mode – Move to Trash (recoverable, used for posts and comments)

Customization

You can modify the default settings through the admin interface or by adding the following to your wp-config.php file:

// Custom batch size
define('WWSSC_BATCH_SIZE', 1000);

Support

For support, feature requests, or bug reports, please visit our support page.

Privacy

This plugin does not collect, store, or transmit any user data outside of your WordPress installation. All operations are performed locally on your server.

Requirements

  • WordPress 5.0 or higher
  • PHP 8.0 or higher
  • Administrator privileges

Credits

Developed by WizzyWeb Private Limited

Important

Always backup your database before running any cleanup operations. This plugin performs destructive operations that cannot be undone.

Screenshots

Installation

  1. Upload the plugin files to the /wp-content/plugins/smart-spam-cleaner directory, or install the plugin through the WordPress plugins screen directly.
  2. Activate the plugin through the ‘Plugins’ screen in WordPress
  3. Use the Users Delete Users & Spam Posts screen to configure and run the cleanup

FAQ

Where is the user guide?

Open Delete Spams How to Use in wp-admin. The same topics are available from the Help tab on the cleanup, settings, and guide screens.

Is this plugin safe to use?

Yes, the plugin includes several safety measures:
* Defaults to the subscriber role and never deletes administrators
* Protect list, dry run, and preview are available before a real deletion
* Requires administrator privileges to run
* Includes confirmation dialogs
* Provides detailed logging for transparency
* Always backup your database before running cleanup operations

How do I configure the filters?

  1. Go to Users Spam Filter Settings
  2. Add your desired keywords and domains
  3. Choose your filter condition (AND/OR)
  4. Save settings
  5. Run the cleanup from the main plugin page

What’s the difference between AND and OR conditions?

  • OR Condition – Delete user if they match ANY keyword OR domain filter
  • AND Condition – Delete user only if they match ALL keyword AND domain filters

How do include/exclude domains work?

  • Include Domains – Only delete users with these email domains
  • Exclude Domains – Never delete users with these email domains (e.g., gmail.com)
  • If Include is empty, all domains are targeted except excluded ones
  • If Exclude is empty, no domains are protected

What’s the difference between trash and permanent deletion for posts?

  • Move to Trash – Posts are moved to WordPress trash bin where they can be recovered or permanently deleted later
  • Permanent Delete – Posts are immediately and permanently deleted from the database (cannot be recovered)
  • Recommendation – Use “Move to Trash” for safety, then review and permanently delete from trash if needed

How long does the cleanup take?

The duration depends on:
* Number of users/posts to process
* Server performance
* Batch size settings
* WordPress cron frequency

For large sites, the process may take several hours but runs in the background.

Can I stop the cleanup process?

Yes. While a cleanup is running, use Cancel cleanup on the main plugin screen. The current batch is allowed to finish. Scheduled follow-up batches are cleared, the saved cursor is discarded, and the dry-run flag is cleared. Users or posts already deleted in earlier batches are not restored. You do not need to deactivate the plugin.

What is a dry run?

Check Dry run on the cleanup form before starting. The plugin walks the same batches and writes “would delete” or “would trash” lines to the log, including the match reason. It does not call user or post deletion. The flag lasts only for that run.

What is the protect list?

On Spam Filter Settings, add one email per line and one user ID per line. Those accounts are never deleted, even when they match keyword or domain filters. User preview does not count them as matches. The list is saved with the other filter settings and is removed on uninstall.

What happens if the process is interrupted?

The plugin uses batch processing with progress tracking. If a batch stops without cancel, open the plugin screen again and it can continue from the saved cursor. Cancel cleanup clears that cursor, so the next start begins a new scan.

Can I customize the spam keywords?

Yes! You can add, remove, or modify keywords through the Spam Filter Settings page. The interface allows you to dynamically manage your keyword lists.

Does this affect my site’s performance?

The plugin is designed to minimize performance impact:
* Runs in background via cron jobs
* Processes data in small batches
* Uses efficient database queries
* Includes built-in delays between batches

Where can I find the cleanup log?

All cleanup activities are logged to: wp-content/uploads/smart-spam-cleaner/smart-spam-cleaner.log

The log file contains:
* Timestamps for all operations
* Number of users/posts processed in each batch
* Success/failure status for each deletion
* Completion messages

Can I use this plugin programmatically?

Yes! You can customize filters using WordPress filters:

add_filter('wwssc_user_filters', function($filters) {
    $filters['keywords'][] = 'custom_keyword1';
    $filters['keywords'][] = 'custom_keyword2';
    $filters['domains']['include'][] = 'spamdomain.com';
    $filters['domains']['exclude'][] = 'trusted.com';
    $filters['condition'] = 'AND';
    return $filters;
});

add_filter('wwssc_post_filters', function($filters) {
    $filters['keywords'][] = 'custom_keyword1';
    $filters['keywords'][] = 'custom_keyword2';
    return $filters;
});

Can I change the batch size?

Yes! You can configure batch size in the settings page (range: 50-2000).

You can also define a custom batch size in your wp-config.php file:

define('WWSSC_BATCH_SIZE', 1000);

Reviews

There are no reviews for this plugin.

Contributors & Developers

“Smart Spam Cleaner” is open source software. The following people have contributed to this plugin.

Contributors

Translate “Smart Spam Cleaner” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

Unreleased

  • NEW: How to Use admin page and Help tabs for filters, dry run, protect list, cancel, and logs.

2.3.0

  • NEW: Choose which user roles to scan. The default remains subscriber. Administrator is never selectable or deleted.
  • NEW: Choose public post types and statuses (published, draft, pending, private). The default remains published posts.
  • NEW: Comment cleanup reuses the post keyword list on comment content, author name, and author email. Approved and held comments only.
  • NEW: Comment preview, dry run, and cancel use the same batch lock and cursor as users and posts.
  • NOTE: The content deletion mode now applies to both posts and comments. Existing sites keep subscriber, post, and publish until you change the settings.

2.2.0

  • NEW: Protect list for emails and user IDs that are never deleted.
  • NEW: Dry run on the cleanup form. Logs would-delete and would-trash lines and skips real deletion.
  • NEW: Cancel cleanup between batches without deactivating the plugin. Already deleted items are not restored.
  • NEW: Non-destructive user and post previews (up to 2,000 scanned items, 50-row sample, matched rule).
  • FIXED: Post preview no longer trashes or deletes a demo post.
  • NOTE: A new cleanup cannot start while another job is still running.

2.1.0

  • FIXED: User cleanup now honors include/exclude domains and AND/OR condition from settings (removed hardcoded gmail shortcut).
  • FIXED: Post cleanup scans title and content, matching documented behavior and preview logic.
  • NEW: Shared filter helpers in includes/wwssc-filters.php with wwssc_user_matches_filters() and wwssc_post_matches_filters().
  • NEW: Runtime wwssc_user_filters and wwssc_post_filters apply_filters hooks wired in batch and preview.
  • IMPROVED: Deletion logs include match reason (keyword/domain) when available.
  • NOTE: Exclude domains now absolutely protect users (e.g. gmail users with spam keywords are no longer deleted).

2.0.2

  • FIXED: File path issues – Now uses wp_upload_dir() instead of WP_CONTENT_DIR
  • FIXED: Removed wp_set_current_user() call from cron function
  • FIXED: Removed Plugin URI from header
  • IMPROVED: Better error handling for uploads directory failures
  • IMPROVED: Added documentation comments explaining WordPress best practices

2.0.0

  • NEW: Dynamic filter configuration system
  • NEW: Configurable spam keywords and email domains
  • NEW: Include/exclude domain functionality
  • NEW: AND/OR condition logic for filters
  • NEW: Post deletion mode (trash vs permanent delete)
  • NEW: Settings page with modern UI
  • NEW: Real-time filter management
  • IMPROVED: Complete rewrite with modern architecture
  • IMPROVED: Enhanced UI with responsive design
  • IMPROVED: Better error handling and logging
  • IMPROVED: AJAX-powered admin interface

1.0.0

  • Initial release with basic functionality
  • Background processing via WP-Cron
  • Basic spam detection
  • Simple admin interface