Skip to content

Instantly share code, notes, and snippets.

@arfinmilondev
Last active May 29, 2025 06:20
Show Gist options
  • Select an option

  • Save arfinmilondev/c2d10b27be2abde4b25e1fb6339fadb2 to your computer and use it in GitHub Desktop.

Select an option

Save arfinmilondev/c2d10b27be2abde4b25e1fb6339fadb2 to your computer and use it in GitHub Desktop.
Remove user which has customer user role from database SQL code
DELETE u, um
FROM wp_users u
LEFT JOIN wp_usermeta um ON um.user_id = u.ID
WHERE u.ID IN (
SELECT user_id
FROM (
SELECT user_id
FROM wp_usermeta
WHERE meta_key = 'wp_capabilities'
AND meta_value LIKE '%customer%'
) AS customer_users
);
🛠️ Notes:
This query:
- Deletes from wp_users and wp_usermeta.
- Targets users who have a meta_key of wp_capabilities with customer in the role.
- If your table prefix is not wp_, replace it throughout the query.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment