Last active
September 22, 2024 09:06
-
-
Save carlosleopoldo/5897807 to your computer and use it in GitHub Desktop.
Delete all orphans user meta in WordPress
This file contains 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 FROM wp_usermeta | |
WHERE NOT EXISTS ( | |
SELECT * FROM wp_users | |
WHERE wp_usermeta.user_id = wp_users.ID | |
) |
This is very useful. Thank you @carlosleopoldo
It was Great! worked for me.
Bravo!
Found a shorter one:
DELETE FROM wp_usermeta WHERE user_id NOT IN (SELECT ID FROM wp_users);
Deleted my admin user for some reason. Dev site so I'm safe.
nice
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks - helped me get rid of 900k rows of usermeta after removing customers from a Woocommerce site for export 👍