Skip to content

Instantly share code, notes, and snippets.

@mustardBees
Forked from dlh01/distribute_user.sh
Last active August 26, 2022 13:33
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 mustardBees/a29a5b042dd28e22e0897a961f8cc883 to your computer and use it in GitHub Desktop.
Save mustardBees/a29a5b042dd28e22e0897a961f8cc883 to your computer and use it in GitHub Desktop.
WP-CLI: Add a user to all sites in a network
#!/bin/bash
# Save script, run chmod +x on it, then...
# 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