#!/usr/bin/env bash ## Description: Resets the password of all users using WP-Cli ## Usage: wp-userrs ## Example: "ddev wp-userrs" WP_PATH=$(realpath $PWD/$DDEV_DOCROOT) WP_SITES=$(wp site list --quiet --path=$WP_PATH) IS_SINGLE_SITE=$? if [[ $IS_SINGLE_SITE -eq 1 ]]; then echo 'Is singlesite.' WP_USERS=$(wp user list --path=$WP_PATH --fields=user_login --format=csv | sed -e '1d') echo 'Wordpress users:' echo $WP_USERS wp user update --path=$WP_PATH --user_pass=asdf1234 --skip-email $WP_USERS fi if [[ $IS_SINGLE_SITE -eq 0 ]]; then echo 'Is multisite.' echo $WP_SITES for WP_SITE in $WP_SITES; do WP_USERS=$(wp user list --path=$WP_PATH --url="$WP_SITE" --fields=user_login --format=csv | sed -e '1d') echo 'Wordpress users:' echo $WP_USERS wp user update --path=$WP_PATH --url="$WP_SITE" --user_pass=asdf1234 --skip-email $WP_USERS done fi #for WORDPRESS_URL in $(wp site list --field=url); do # # WORDPRESS_USERS=$(wp user list --path=$WORDPRESS_PATH --url='$WORDPRESS_URL' --fields=user_login --format=csv 2>/dev/null | sed -e '/eval/d;/^$/d;' | sed -e '1d') # echo === Site === # echo $WORDPRESS_URL # echo === Users === # wp user list --url=$WORDPRESS_URL --fields=user_login --format=csv 2>/dev/null | sed -e '/eval/d;/^$/d;' | sed -e '1d' # # echo $WORDPRESS_USERS #done