File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ user_count=0;
4848# Loop over the entire CSV file.
4949while IFS=" ," read -r username email role superadmin; do
5050
51- # Create the user.
52- if wp_skip_all user create --porcelain " $username " " $email " --role=" $role " > /dev/null ; then
51+ # Create the user. Only output WPCLI success message on successful creation.
52+ if new_user_id= $( wp_skip_all user create --porcelain " $username " " $email " --role=" $role " >&1 ) ; then
5353
5454 # Update the count for each successful user creation.
5555 (( user_count++ )) ;
@@ -61,10 +61,20 @@ while IFS="," read -r username email role superadmin; do
6161
6262 wp_skip_all super-admin add $username ;
6363
64+ else
65+
66+ for site_url in $( wp_skip_all site list --field=" url" --archived=0 --deleted=0 --spam=0) ; do
67+
68+ # The user is not a superadmin so add them to each site individually.
69+ wp_on_site user set-role " $new_user_id " " $role " ;
70+
71+ done ;
72+
6473 fi
6574
6675 else
6776
77+ # Output any errors from WPCLI.
6878 >&2
6979
7080 fi
You can’t perform that action at this time.
0 commit comments