Make WordPress Core

Opened 3 years ago

Last modified 42 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 18 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 18 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 (16)

#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
18 months ago

  • Focuses multisite added

@stefan.velthuys
18 months ago

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

@stefan.velthuys
18 months ago

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

#4 @stefan.velthuys
18 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.


18 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
18 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.


2 months 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
2 months 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:


2 months ago
#9

These changes look very good!

#10 @ocean90
2 months ago

  • Milestone changed from Awaiting Review to 7.0

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


5 weeks ago

This ticket was mentioned in Slack in #core by fakhriaz. View the logs.


5 weeks ago

#13 @fakhriaz
4 weeks ago

Patch Test Report

Description

This report validates whether the indicated patch works as expected.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/10502

Environment

  • WordPress: 6.9
  • PHP: 8.2.29
  • Server: nginx/1.29.3
  • Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 143.0.0.0
  • OS: Linux
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None activated
  • Plugins:
    • Gutenberg 22.2.0
    • Test Reports 1.2.1

Actual Results

  1. ?Most Issues resolved with patch, except the last point with inconsistent results❓.

Additional Notes

-✅❓ Same step (When deleting multiple users in single-site installations, you can now select what should happen with their contents individually) => check last bullet point below for more details.

Supplemental Artifacts

Attachments: video attached to each step
With one screenshot of console log.


Steps

git restore .
npm run grunt patch:https://github.com/WordPress/wordpress-develop/pull/10502
npm run build:dev
  • Every plugin & theme 2025 up to date.
  • Updated WP to 6.9
  • Deleted all previous users & posts
  • Created 3 users with the role of editor each (usr1, usr2 & usr3)
  • usr1, usr2 & usr3 updated role to authors
  • (deleted all previous categories except Uncategorized)
  • created post 1, post 2 & post 3
  • assigned post 1 to usr1, post 2 to usr2 & post 3 to usr3 using "Quick Edit"
  • ✅deleted usr1 and assigned content usr2 as in the video below

https://drive.google.com/file/d/1oHIeCJEcx6Jt0IhQLtilB-bERP_KJV3X/view?usp=sharing
or (as described in test steps)

  • ✅Delete multiple users and select another user for attribution

here we have one user left the admin.
https://drive.google.com/file/d/1YF-b5j8guL60xutO623YCcD0iLjDeOdt/view?usp=drive_link

  • ✅Recreated 3 other users and assigned 1 post to each
  • ✅Deleting users should not be possible if not all users that will be deleted have a selection for their content attribution:

https://drive.google.com/file/d/1Oq7AFydhbAJQBMDhvQ2P20igE6e89OPl/view?usp=sharing

  • ✅You should not be able to select a user for content attribution that will be deleted

https://drive.google.com/file/d/1IqpQ7-I9RiPp1-O3T7OSHLMnBddjLdkH/view?usp=sharing

  • ✅No default selection for content attribution, so you have to actively decide what should happen.

https://drive.google.com/file/d/1WnF3-qAmXOLkcsa-OnftwqCesTIt2t8q/view?usp=sharing
-❌ When deleting multiple users in single-site installations, you can now select what should happen with their contents individually

https://drive.google.com/file/d/1szH2ppBAWL-LoZlX0OhziwdGQCppfKke/view?usp=drive_link

https://drive.google.com/file/d/1j2TPSy_7HwEBmFEWBhUbA0u1FloFncQk/view?usp=sharing
-✅❓ Same step (When deleting multiple users in single-site installations, you can now select what should happen with their contents individually)
No idea why it worked before on a previous test when I did not run: npm run build:dev, besides, in previous tests sometimes it works sometimes it does not, but when I did this screencast it worked
https://drive.google.com/file/d/1lRmaWuH-Q86c-8AzBS_C3Z_WHNs5tZDH/view?usp=drive_link

Last edited 4 weeks ago by fakhriaz (previous) (diff)

#14 @ozgursar
3 days ago

Test Report

Description

This report validates whether the indicated patch works as expected.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/10502

Environment

  • WordPress: 6.9-beta4-20251111.110442
  • PHP: 8.3.29
  • Server: PHP.wasm
  • Database: WP_SQLite_Driver (Server: 8.0.38 / Client: 3.51.0)
  • Browser: Opera
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.3
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.1

Actual Results

  1. ✅ Issue resolved with patch.

Screenshots

Multisite Installation

Before (multiple users) After (multiple users) After (single user)
https://i.snipboard.io/tUvchK.jpg https://i.snipboard.io/7LyZ5g.jpg https://i.snipboard.io/E0C6YV.jpg

Singlesite Installation

Before (multiple users) After (multiple users)
https://i.snipboard.io/h0cmfx.jpg https://i.snipboard.io/WbCDVg.jpg

Additional Notes

  • Confirmed Fix1: On multisite installations the options to delete all content is NOT pre-selected by default.
  • Confirmed Fix2: On multisite installations title changed from Users to Delete Users.
  • Confirmed Fix3: On singlesite installations, when deleting multiple users, you can now select what should happen with their contents individually.
  • Confirmed Fix4: You can not select a user for content attribution that will be deleted.
Last edited 42 hours ago by ozgursar (previous) (diff)
Note: See TracTickets for help on using tickets.