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 while true; do
echo "-------------------------------------" echo "-------------------------------------"
read -r -p "Action for \"$TARGET\" [d/c/s/x]? " ACT < /dev/tty read -r -p "Action for \"$TARGET\" [d/c/s/x]? " ACT < /dev/tty
skip=0;
case "$ACT" in case "$ACT" in
[Dd]* ) [Dd]* )
# read -r -p "Really DELETE \"$TARGET\" ? (y/n, default: y) " CONF < /dev/tty # 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 fi
echo "Available admin usernames for reassignment: ${OTHER_USERS[*]}" echo "Available admin usernames for reassignment: ${OTHER_USERS[*]}"
while true; do 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} REASSIGN=${REASSIGN:-$DEFAULT_USER}
DEFAULT_USER=$REASSIGN DEFAULT_USER=$REASSIGN
if printf '%s\n' "${OTHER_USERS[@]}" | grep -qx "$REASSIGN"; then if printf '%s\n' "${OTHER_USERS[@]}" | grep -qx "$REASSIGN"; then
break break
fi fi
if [[ "$REASSIGN" =~ ^[Ss]$ ]]; then
echo "Skipping reassignment."
skip=1;
break
fi
if [[ "$REASSIGN" =~ ^[0-9]+$ ]]; then if [[ "$REASSIGN" =~ ^[0-9]+$ ]]; then
break break
fi fi
echo "Invalid username. Please choose one of: ${OTHER_USERS[*]}" echo "Invalid username. Please choose one of: ${OTHER_USERS[*]}"
done done
if [ $skip -eq 1 ]; then
break
fi
# delete by username, reassign by username # delete by username, reassign by username
RUN="$WP_RUN user delete $ID --reassign=$REASSIGN --yes --skip-plugins --skip-themes" RUN="$WP_RUN user delete $ID --reassign=$REASSIGN --yes --skip-plugins --skip-themes"
eval "$RUN" eval "$RUN"