Last active
May 29, 2025 06:20
-
-
Save arfinmilondev/c2d10b27be2abde4b25e1fb6339fadb2 to your computer and use it in GitHub Desktop.
Remove user which has customer user role from database SQL code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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