Skip to content

Instantly share code, notes, and snippets.

@CatEntangler
Last active December 2, 2020 16:39
Show Gist options
  • Save CatEntangler/5911d7382dc645f652ed to your computer and use it in GitHub Desktop.
Save CatEntangler/5911d7382dc645f652ed to your computer and use it in GitHub Desktop.
Anonymize wordpress user email addresses for cloning purposes. Exclude specific domain names to keep admin/selected users intact. Prefix so that addresses are still unique.
SET @domains='domain1.com|domain2.com';
UPDATE wp_users prod_users,
( select ID FROM wp_users WHERE user_email NOT REGEXP @domains) clone_users
SET prod_users.user_email = CONCAT('DC_', prod_users.ID, '@example.org')
WHERE prod_users.user_email NOT REGEXP @domains;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment