mirror of
https://github.com/myvesta/vesta
synced 2025-08-20 05:14:10 -07:00
v-change-wordpress-admin-passwords: add option to skip content reassignment during user deletion
This commit is contained in:
parent
9eade5a7df
commit
f64968ba91
1 changed files with 10 additions and 1 deletions
|
@ -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"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue