v-change-wordpress-admin-passwords: accept integer as id of user, support for custom php version

This commit is contained in:
Peca 2025-07-10 17:49:15 +02:00
commit 54abc58c4e

View file

@ -24,7 +24,12 @@ WP_PATH="/home/$USER/web/$DOMAIN/public_html"
[ ! -f "$WP_PATH/wp-config.php" ] && { echo "WordPress is not installed on this domain."; exit 1; }
# WP-CLI wrapper
WP_RUN=(/usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes)
if [ ! -z "$PHP" ]; then
WP_RUN=(PHP=$PHP /usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes)
else
WP_RUN=(/usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes)
fi
return_code=$?
if [ $return_code -ne 0 ]; then
@ -86,9 +91,11 @@ while IFS=',' read -r ID LOGIN EMAIL; do
REASSIGN=${REASSIGN:-$DEFAULT_USER}
if printf '%s\n' "${OTHER_USERS[@]}" | grep -qx "$REASSIGN"; then
break
else
echo "Invalid username. Please choose one of: ${OTHER_USERS[*]}"
fi
if [[ "$REASSIGN" =~ ^[0-9]+$ ]]; then
break
fi
echo "Invalid username. Please choose one of: ${OTHER_USERS[*]}"
done
# delete by username, reassign by username
"${WP_RUN[@]}" user delete "$LOGIN" --reassign="$REASSIGN" --yes --skip-plugins --skip-themes