v-change-wordpress-admin-passwords: add option to skip content reassignment during user deletion

This commit is contained in:
Peca 2025-07-17 14:36:37 +02:00
commit f64968ba91

View file

@ -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"