1111source ' source/includes.sh' ;
1212
1313# Check if this is a multisite/network installation of WordPress.
14- is_multisite=$( wp config get MULTISITE) ;
14+ is_multisite=$( wp_skip_all config get MULTISITE) ;
1515
1616echo ;
1717
@@ -31,7 +31,7 @@ read -r -p 'Path to CSV file with users [./user-create.csv]: ' csv_path;
3131[[ -z " $csv_path " ]] && csv_path=' ./user-create.csv' ;
3232
3333# Ensure the file actually exists.
34- [[ ! -f " $csv_path " ]]; then
34+ if [[ ! -f " $csv_path " ]]; then
3535
3636 echo " The file you provided does not exist: ${csv_path} " ;
3737 exit 1;
@@ -49,17 +49,25 @@ user_count=0;
4949while IFS=" ," read -r username email role superadmin; do
5050
5151 # Create the user.
52- new_user_id= $( wp_skip_all user create --porcelain " $username " " $email " --role=" $role " ) ;
52+ if wp_skip_all user create --porcelain " $username " " $email " --role=" $role " > /dev/null ; then
5353
54- # Check if the user should be a superadmin .
55- if [[ " 1 " == " $superadmin " ]] ; then
54+ # Update the count for each successful user creation .
55+ (( user_count ++ )) ;
5656
57- wp super-admin add $username ;
57+ echo " ' $username ' was successfully created. " ;
5858
59- fi
59+ # Check if the user should be a superadmin.
60+ if [[ " 1" == " $superadmin " ]]; then
61+
62+ wp_skip_all super-admin add $username ;
63+
64+ fi
6065
61- # Update the count for each successful user creation.
62- [[ new_user_id > 0 ]] && (( user_count++ )) ;
66+ else
67+
68+ >&2
69+
70+ fi
6371
6472done < " $csv_path "
6573
0 commit comments