Skip to main content
< All Topics

Deleting WordPress Subscribers via mySQL

If your WordPress site has accumulated a large number of subscribers — particularly from a membership plugin, newsletter signup, or open registration — you may need to bulk delete them from the database. This script does that efficiently via MySQL without needing a plugin or PHP.

This script will delete all WordPress subscribers who have never commented on a post. Subscribers who have commented are preserved.

Before you begin

  • Take a full database backup before running any SQL script. This operation cannot be undone.
  • You will need access to your database via phpMyAdmin, MySQL Workbench, or a similar tool
  • The script assumes standard WordPress table prefixes (wp_). If your installation uses a custom prefix, update the table names accordingly.
  • Read through the script and its comments before running it — the delete lines are intentionally commented out so you can do a dry run first

The script

How to use this script

  1. Back up your database
  2. Open your database management tool and select your WordPress database
  3. Paste the script into the SQL query window and run it with the delete lines still commented out — this is your dry run
  4. Verify the results look correct
  5. Uncomment the two delete lines and run the script again to perform the actual deletion

Important notes

  • This script only targets users with the subscriber role. If you have modified WordPress roles or want to target a different role, review the script carefully before running it.
  • If your site uses WooCommerce, a membership plugin, or an LMS, subscribers may have associated order or enrollment records. Deleting them at the database level may leave orphaned data. Contact us if you are unsure.
  • Subscribers are assumed not to be post authors. If you have subscribers who are also authors, add an additional exclusion before uncommenting the delete lines.

Related articles

Need help managing your WordPress database or site? Glimmernet offers WordPress maintenance and managed hosting services.

Tags:

Submit a Comment

Your email address will not be published. Required fields are marked *