WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#34655 closed enhancement (wontfix)

Allow pre-filtering of role changes on WP_User

Reported by: tellyworth Owned by: pento
Milestone: Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch
Focuses: Cc:

Description

It would be useful to have pre-filters for WP_User::set_role() and friends, so a plugin could monitor or block certain roles from being applied.

For example, on multisite, it may be desirable to prevent roles from being changed on certain blogs.

Attachments (2)

34655.diff (1.6 KB) - added by tellyworth 3 years ago.
Add pre-filters to add_role(), remove_role(), set_role().
34655.2.diff (1.7 KB) - added by pento 3 years ago.

Download all attachments as: .zip

Change History (6)

@tellyworth
3 years ago

Add pre-filters to add_role(), remove_role(), set_role().

#1 @pento
3 years ago

  • Component changed from General to Users
  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.4
  • Owner set to pento
  • Status changed from new to assigned

@pento
3 years ago

#2 @pento
3 years ago

34655.2.diff refreshes the patch to apply cleanly against trunk, makes some coding style tweaks.

In set_role(), it's possible to send an empty role, which will cause all user roles to be removed. This existing behaviour is incompatible with the short-circuit behaviour we're after.

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


3 years ago

#4 @pento
3 years ago

  • Milestone 4.4 deleted
  • Resolution set to wontfix
  • Status changed from assigned to closed

Per the Slack discussion, this isn't really the right solution.

Note: See TracTickets for help on using tickets.