Skip to content

Instantly share code, notes, and snippets.

@paulcushing
Created April 23, 2025 16:41
Show Gist options
  • Save paulcushing/84b09d7966c47978c26bfe2759a34212 to your computer and use it in GitHub Desktop.
Save paulcushing/84b09d7966c47978c26bfe2759a34212 to your computer and use it in GitHub Desktop.
When you need to remove subscribers from a WordPress server and there are too many to user the web interface, use this SQL to delete them and then cleanup the associated metadata.
# Wordpress Management
# Remove all subscribers using SQL Query
# Delete all of the users with Subscribe capabilities
DELETE FROM wp_users WHERE ID IN ( SELECT user_id FROM wp_usermeta WHERE meta_key = 'wp_capabilities' AND meta_value LIKE '%subscriber%' );
# Cleanup the meta (bonus! it cleans up all meta not associated with an existing account)
DELETE FROM wp_usermeta WHERE user_id NOT IN ( SELECT id FROM wp_users );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment