Skip to content

Instantly share code, notes, and snippets.

@lsemenenko
Created January 21, 2021 03:49
Show Gist options
  • Save lsemenenko/8282e34ef722e9e75843396ea3d13607 to your computer and use it in GitHub Desktop.
Save lsemenenko/8282e34ef722e9e75843396ea3d13607 to your computer and use it in GitHub Desktop.
Change all users with specific role to another role across MU network with WP-CLI
for i in $(sudo -u www-data wp site list --field=url); \
do
echo ${i}; \
a="$(sudo -u www-data wp user list --url=${i} --role=SuperUser --field=user_login)"; \
if [[ ! -z "${a}" ]]; then \
sudo -u www-data wp user --url="${i}" update "${a}" --role "administrator"; \
echo "User ${a} updated for site ${i}."; \
fi; \
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment