From f64968ba918e10040325315eaaa5e8f09657d72b Mon Sep 17 00:00:00 2001 From: Peca Date: Thu, 17 Jul 2025 14:36:37 +0200 Subject: [PATCH] v-change-wordpress-admin-passwords: add option to skip content reassignment during user deletion --- bin/v-change-wordpress-admin-passwords | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/v-change-wordpress-admin-passwords b/bin/v-change-wordpress-admin-passwords index 6ab4ad0e..eae5b078 100644 --- a/bin/v-change-wordpress-admin-passwords +++ b/bin/v-change-wordpress-admin-passwords @@ -81,6 +81,7 @@ while IFS=',' read -r ID LOGIN EMAIL; do while true; do echo "-------------------------------------" read -r -p "Action for \"$TARGET\" [d/c/s/x]? " ACT < /dev/tty + skip=0; case "$ACT" in [Dd]* ) # read -r -p "Really DELETE \"$TARGET\" ? (y/n, default: y) " CONF < /dev/tty @@ -97,17 +98,25 @@ while IFS=',' read -r ID LOGIN EMAIL; do fi echo "Available admin usernames for reassignment: ${OTHER_USERS[*]}" while true; do - read -r -p "Reassign content to which username? [default: $DEFAULT_USER] " REASSIGN < /dev/tty + read -r -p "Reassign content to which username? [default: $DEFAULT_USER, s: skip] " REASSIGN < /dev/tty REASSIGN=${REASSIGN:-$DEFAULT_USER} DEFAULT_USER=$REASSIGN if printf '%s\n' "${OTHER_USERS[@]}" | grep -qx "$REASSIGN"; then break fi + if [[ "$REASSIGN" =~ ^[Ss]$ ]]; then + echo "Skipping reassignment." + skip=1; + break + fi if [[ "$REASSIGN" =~ ^[0-9]+$ ]]; then break fi echo "Invalid username. Please choose one of: ${OTHER_USERS[*]}" done + if [ $skip -eq 1 ]; then + break + fi # delete by username, reassign by username RUN="$WP_RUN user delete $ID --reassign=$REASSIGN --yes --skip-plugins --skip-themes" eval "$RUN"