Skip to content

Instantly share code, notes, and snippets.

@cubehrends
Last active January 5, 2022 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cubehrends/f831aeef5af953d8c578eaec25e145d5 to your computer and use it in GitHub Desktop.
Save cubehrends/f831aeef5af953d8c578eaec25e145d5 to your computer and use it in GitHub Desktop.
obfuscate user data for privacy in WordPress database
UPDATE wp_users AS user
INNER JOIN wp_usermeta AS meta ON meta.user_id = user.ID
SET
user.user_email = CONCAT(SUBSTRING(MD5(RAND()), -10), "@", SUBSTRING(MD5(RAND()), -10), ".com"),
/** random strings */
user.user_pass = CONCAT("pass_", SUBSTRING(MD5(RAND()), -10)),
user.user_nicename = CONCAT("nice_", SUBSTRING(MD5(RAND()), -10)),
user.user_login = CONCAT("login_", SUBSTRING(MD5(RAND()), -10)),
user.display_name = CONCAT("display_", SUBSTRING(MD5(RAND()), -10))
/** except our admins */
WHERE meta.meta_key = 'wp_capabilities' AND meta.meta_value NOT LIKE '%administrator%';
DELETE FROM wp_usermeta
WHERE meta_key = 'nickname';
DELETE FROM wp_usermeta
WHERE meta_key = 'first_name';
DELETE FROM wp_usermeta
WHERE meta_key = 'last_name';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment