Skip to content

Instantly share code, notes, and snippets.

@chrisjangl
Last active November 24, 2021 12:28
Show Gist options
  • Save chrisjangl/d1a350caf0ddfea95edbf82c5f95cbab to your computer and use it in GitHub Desktop.
Save chrisjangl/d1a350caf0ddfea95edbf82c5f95cbab to your computer and use it in GitHub Desktop.
Working from a list of WordPress sites on a shared hosting environment (sites.txt), reset the password for a given user account on each of them. It also creates a report of the admin users on each site
i=1
touch users.txt
COUNT=$(wc -l sites.txt)
for SITE in $(cat sites.txt)
do
cd $SITE
echo "Working on $SITE ($i of $COUNT)..."
echo "## $SITE" >> ../users.txt
wp user list --role=administrator --fields=user_login,user_email >> ../users.txt
echo "----------------" >> ../users.txt
echo " " >> ../users.txt
echo " " >> ../users.txt
echo " " >> ../users.txt
wp user update <user_login> --user_pass=<user_pass>
((i=i+1))
clear
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment