Make WordPress Core

Opened 3 years ago

Last modified 17 hours ago

#56914 new enhancement

Better guide users when deleting other users

Reported by: stefanvelthuys's profile stefan.velthuys Owned by:
Milestone: 7.0 Priority: normal
Severity: normal Version: 3.5
Component: Users Keywords: has-screenshots has-patch needs-testing
Focuses: ui, multisite Cc:

Description

When deleting a user, you have to decide, if their content should be assigned to another person, or if that content should be deleted.

The option to delete the content is quite drastic, compared to assigning it.
Since this option is not reversible, it should be made clearer, what impact this has.

I see multiple ways to warn the users, what they're about to do:

  • Mark the option to delete bold and use a different color (e.g. red)
  • Users have to confirm in a second step, if the delete option is selected
  • By default, pre-select the option to assign the content to another user
  • Use a kind of "Danger Zone" like GitHub does for deleting repositories

But maybe, something as simple as showing the amount of content could suffice:

  • Delete all content (19 posts, 2 pages, 31 images)

Attachments (2)

delete-user-current.png (65.6 KB) - added by stefan.velthuys 17 months ago.
Screenshots of the current user deletion screen. Left: single site. Right: multisite
delete-user-proposal-step-1.png (65.2 KB) - added by stefan.velthuys 17 months ago.
Screenshots of a proposed first step for the user deletion screen. Left: single site. Right: multisite

Download all attachments as: .zip

Change History (13)

#2 @hellofromTonya
3 years ago

  • Version changed from trunk to 3.5

Hello @stefanvelthuys,

Welcome to WordPress Core's Trac! Thank you for opening this enhancement ticket with your suggestions to improve the user experience :)

I'm doing some ticket triage for contributor discoverability.

Changing the Version to 3.5.0 which is when the choice of content deletion or reassignment was introduced (see [22166]).

#3 @stefan.velthuys
17 months ago

  • Focuses multisite added

@stefan.velthuys
17 months ago

Screenshots of the current user deletion screen. Left: single site. Right: multisite

@stefan.velthuys
17 months ago

Screenshots of a proposed first step for the user deletion screen. Left: single site. Right: multisite

#4 @stefan.velthuys
17 months ago

  • Keywords has-screenshots added

This applies primarily to multisites.

On single site installations, the options to delete all content is not pre-selected.
But on Multisite, the option is pre-selected.

In the first step, I'd propose that the behaviour for multisites should be similar to the behaviour in single sites: That the option is NOT pre-selected.

Additionally, the title should reflect the content.
Currently, in the multisite screen, the title is just "Users". That could be changed to "Delete Users".

This ticket was mentioned in PR #7095 on WordPress/wordpress-develop by AKSHAT2802.


17 months ago
#5

  • Keywords has-patch added

This PR solves the issue of giving more relevant information to a user when deleting other users.

#6 @akshat2802
17 months ago

Hey @stefanvelthuys
I have added a patch for current requirements. I want to contribute further to the ticket if core members approve any additional requirements.

This ticket was mentioned in PR #10502 on WordPress/wordpress-develop by @hubeRsen.


4 weeks ago
#7

This pull request refactors and improves the user deletion workflow in the WordPress admin (for single- and multisite installations), focusing on enhancing the usability, accessibility, and reliability of the "Delete Users" form. The main changes include updating the form UI to require explicit choices for content deletion or reassignment, improving the handling of users with or without content, and replacing legacy inline JavaScript with a modern, unobtrusive approach.

User Deletion Form Improvements

  • The "Delete Users" form now requires admins to explicitly select an action (delete content or reassign) for each user with content, using radio buttons and dropdowns. The form disables the submit button until all required choices are made, improving clarity and preventing accidental deletions. [diffhunk://#diff-de543bffdeee1addfaf033fddada9b2dc79945d81929641084491b304919d1a8L304-R306 [1]] [diffhunk://#diff-de543bffdeee1addfaf033fddada9b2dc79945d81929641084491b304919d1a8L389-R416 [2]] [diffhunk://#diff-de543bffdeee1addfaf033fddada9b2dc79945d81929641084491b304919d1a8L432-R438 [3]] [diffhunk://#diff-b9e9194f24d2a3548ae0b16b6bde5e0c7756a2b7668bed4d1040093e00550bf6R2357-R2412 [4]] [diffhunk://#diff-9da780dbae8bdb0748b821115e1a29aa416b20db16ad2d10006cfc353bd19e98R867-R885 [5]] [diffhunk://#diff-9da780dbae8bdb0748b821115e1a29aa416b20db16ad2d10006cfc353bd19e98L933-R977 [6]] [diffhunk://#diff-9da780dbae8bdb0748b821115e1a29aa416b20db16ad2d10006cfc353bd19e98L999-R1006 [7]]
  • For users without any content, the form automatically sets the delete option and informs the admin, streamlining the process.

JavaScript and Accessibility Enhancements

  • Legacy inline JavaScript for the user deletion form is removed and replaced with a new script in common.js. This script ensures the submit button is only enabled when all necessary options are selected, and improves accessibility by working with the new form structure. [diffhunk://#diff-3d5efd27772e26113a78312f09edc36408f9758b18ebb5f8cbf1e0b96081ff38L564-L583 [1]] [diffhunk://#diff-b9e9194f24d2a3548ae0b16b6bde5e0c7756a2b7668bed4d1040093e00550bf6R2357-R2412 [2]]
  • The deprecated function delete_users_add_js() is removed from active usage and marked as deprecated for backward compatibility. [diffhunk://#diff-3d5efd27772e26113a78312f09edc36408f9758b18ebb5f8cbf1e0b96081ff38L564-L583 [1]] [diffhunk://#diff-b25dd8db3f91b25304c91cb07e56114ab74c18f39f99fad9879449edbaf789c3R1592-R1602 [2]]

Code Consistency and Cleanup

  • Updates to variable naming and array handling ensure consistency between single-site and multisite user deletion flows. [diffhunk://#diff-23793c61a4e874a8141bddb2ded65eca1de82aecee0bee4de9b3384ee3561645R59-R61 [1]] [diffhunk://#diff-23793c61a4e874a8141bddb2ded65eca1de82aecee0bee4de9b3384ee3561645L75-R76 [2]] [diffhunk://#diff-9da780dbae8bdb0748b821115e1a29aa416b20db16ad2d10006cfc353bd19e98L989-R996 [3]]
  • The multisite user deletion confirmation UI is updated to match the improved structure and logic, including the use of fieldsets, radio buttons, and dropdowns for each user's content. [diffhunk://#diff-9da780dbae8bdb0748b821115e1a29aa416b20db16ad2d10006cfc353bd19e98R867-R885 [1]] [diffhunk://#diff-9da780dbae8bdb0748b821115e1a29aa416b20db16ad2d10006cfc353bd19e98L933-R977 [2]]

Backend Logic Adjustments

  • The backend now tracks and processes per-user deletion or reassignment choices using associative arrays, ensuring the correct action is taken for each user. [diffhunk://#diff-de543bffdeee1addfaf033fddada9b2dc79945d81929641084491b304919d1a8L211-R216 [1]] [diffhunk://#diff-de543bffdeee1addfaf033fddada9b2dc79945d81929641084491b304919d1a8L389-R416 [2]]
  • The logic for determining whether users have content is now handled on a per-user basis, rather than globally, allowing for more granular control and messaging. [diffhunk://#diff-de543bffdeee1addfaf033fddada9b2dc79945d81929641084491b304919d1a8L389-R416 [1]] [diffhunk://#diff-de543bffdeee1addfaf033fddada9b2dc79945d81929641084491b304919d1a8R333 [2]]

These changes collectively make the user deletion process safer, more user-friendly, and more maintainable.

Screenshots Multisite

https://github.com/user-attachments/assets/123d4fa7-3b62-416a-b25f-756d6653dfb3
https://github.com/user-attachments/assets/fb2198bb-27cf-4dad-b786-5ce1b8495fb9
https://github.com/user-attachments/assets/d76f7750-9c20-42f0-a0ea-e350d65836a9
https://github.com/user-attachments/assets/2cf101d0-b854-4fba-a6cd-a9cec3efb781
https://github.com/user-attachments/assets/67b047d3-980a-44cc-b065-2af4b8bd1158

Screenshot Singlesite
https://github.com/user-attachments/assets/15d12eb8-075a-4021-a41b-3437cbd93240

Test steps

  • Create up to 3 users (single or multisite)
  • Add posts and assign posts to the created users as author
  • Delete one of the users and select the user the content should be assigned to

or

  • Delete multiple users and select another user for attribution
  • Deleting users should not be possible if not all users that will be deleted have a selection for their content attribution
  • You should not be able to select a user for content attribution that will be deleted
  • No default selection for content attribution, so you have to actively decide what should happen.
  • When deleting multiple users in single-site installations, you can now select what should happen with their contents individually

Trac ticket: https://core.trac.wordpress.org/ticket/56914

Contributors
@ocean90 @krokodok @velthy @KarinChristen

#8 @hubeRsen
4 weeks ago

  • Keywords needs-testing added

@stefanvelthuys we've made some fixes and created a pull request for this issue.
See https://github.com/WordPress/wordpress-develop/pull/10502

@krokodok commented on PR #10502:


4 weeks ago
#9

These changes look very good!

#10 @ocean90
4 weeks ago

  • Milestone changed from Awaiting Review to 7.0

This ticket was mentioned in Slack in #core-test by nikunj8866. View the logs.


17 hours ago

Note: See TracTickets for help on using tickets.