Last active
June 27, 2023 20:25
-
-
Save dlh01/be208e667ec35118126f to your computer and use it in GitHub Desktop.
WP-CLI: Add a user to all sites in a network
This file contains hidden or 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
#!/bin/bash | |
# Usage: ./distribute_user.sh [username] [role] | |
ARGS="$@" | |
echo "Adding user $1 as $2 to all sites" | |
SITES=$(wp site list --field=url --format=csv) | |
for site in $SITES | |
do | |
wp user set-role $1 $2 --url=$site | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI this seems to add the user to the site, but the sites won't appear in the user's drop down list on the backend. You still have to 'add' them in manually