WordPress.org

Make WordPress Core

Opened 7 months ago

Closed 6 months ago

Last modified 6 months ago

#52238 closed defect (bug) (fixed)

Missing option to change multiple users to "No role for this site"

Reported by: bonniebeeman Owned by: johnbillion
Milestone: 5.7 Priority: normal
Severity: normal Version: 3.0
Component: Users Keywords: good-first-bug has-patch needs-testing
Focuses: administration Cc:

Description (last modified by sabernhardt)

It is often critical for the security of a WordPress site to change User roles en masse, but the option to change a user role to "No role for this site" is missing from WordPress User option dropdown list.

Attachments (3)

no role for this site - option missing.png (156.5 KB) - added by bonniebeeman 7 months ago.
Missing option to change user role to "no role for this user"
52238.patch (1.2 KB) - added by ovidiul 6 months ago.
Added the "— No role for this site — " to the bulk user roles change; probably the best implementation would be to add the default role None to the wp_user_roles db option, but that would have it's own complexities
52238.diff (1.4 KB) - added by johnbillion 6 months ago.

Download all attachments as: .zip

Change History (13)

@bonniebeeman
7 months ago

Missing option to change user role to "no role for this user"

#1 @sabernhardt
7 months ago

  • Component changed from General to Users
  • Description modified (diff)
  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hi @bonniebeeman and welcome to Trac!

"None" or "No role for this site" must be a plugin option, as it is not one of the standard WordPress roles.

If that plugin is User Role Editor, you could request that they add it as an option to the Change role dropdown:
User Role Editor support forum

Right now with that plugin, though, you could select all Subscriber-level users and select Subscriber in the Revoke role dropdown. That changes users' role to "None" if the revoke role matches their previous role.

#2 @johnbillion
7 months ago

  • Keywords needs-patch added
  • Milestone set to Awaiting Review
  • Resolution invalid deleted
  • Status changed from closed to reopened

"No role for this site" is a core option, it's only available when editing a single user though. I don't see any reason for it not to be available as a bulk action on the Users screen.

#3 @sabernhardt
7 months ago

My mistake for not checking the Edit User screen. In addition to the bulk edit, would it be worth including this in the dropdown on the Add New User screen?

#4 @johnbillion
7 months ago

  • Keywords good-first-bug added
  • Severity changed from critical to normal
  • Version changed from 5.6 to 3.0

@ovidiul
6 months ago

Added the "— No role for this site — " to the bulk user roles change; probably the best implementation would be to add the default role None to the wp_user_roles db option, but that would have it's own complexities

#5 @ovidiul
6 months ago

  • Keywords has-patch added; needs-patch removed

#6 @johnbillion
6 months ago

  • Keywords needs-testing added
  • Milestone changed from Awaiting Review to Future Release

Thanks for the patch @ovidiul !

@johnbillion
6 months ago

#7 @johnbillion
6 months ago

  • Milestone changed from Future Release to 5.7

52238.diff adjusts the patch slightly so the user's role gets correctly set to an empty string instead of none.

Steps to test:

  1. Visit the Users screen in the admin area
  2. Check the checkbox next to a user
  3. Select "No role for this site" in the "Change role to" dropdown
  4. Click the "Change" button
  5. Confirm the user's role is marked as "None"
  6. Confirm the user shows up when you click the "No role" filter at the top of the Users screen

This isn't something we can add an automated test for (without E2E tests) as it's tightly coupled to the request.

#8 @jeroenrotty
6 months ago

Tested the latest patch and can confirm the testing steps work as described by @johnbillion. None gets applied correctly in bulk.

#9 @johnbillion
6 months ago

  • Owner set to johnbillion
  • Resolution set to fixed
  • Status changed from reopened to closed

In 50228:

Users: Allow the role of users to be bulk changed to no role from the Users listing screen.

This option is already available when editing an individual user, but it was previously missing from the bulk actions.

Props bonniebeeman, sabernhardt, ovidiul, jeroenrotty

Fixes #52238

#10 @johnbillion
6 months ago

In 50229:

Users: Coding standards fixes after [50228].

See #52238

Note: See TracTickets for help on using tickets.