Make WordPress Core

Opened 9 years ago

Closed 17 months ago

Last modified 16 months ago

#43251 closed defect (bug) (fixed)

editable_roles filter doesn't exclude role on multisite

Reported by: eArtboard Owned by: peterwilsoncc
Priority: normal Milestone: 6.8
Component: Users Version: 2.8
Severity: normal Keywords: has-patch has-unit-tests commit
Cc: Focuses: multisite

Description

On a multisite installation I am trying to exclude a role using editable_roles filter.

The role is removed from the dropdown but if I change the role value in the DOM using the inspector I can successfully add the excluded role.

This happens only on multisite installations. On single installations if I try to add an excluded role I get the message “Sorry, you are not allowed to give users that role.”

How to reproduce the issue:

  1. Unset a role using editable_roles filter.
  2. Login with any role that has the capability create_user.
  3. Add a new user changing any role value with the excluded role (using inspector).

Change History (15)

#1 @thomaswm
8 years ago

I think that line 159 in wp-admin/user-new.php is the culprit here. It passes $_REQUEST['role'] to wpmu_signup_user() without checking if the role is editable.

wpmu_signup_user( $new_user_login, $new_user_email, array( 'add_to_blog' => get_current_blog_id(), 'new_role' => $_REQUEST['role'] ) );

#2 @Hareesh Pillai
7 years ago

  • Keywords needs-patch added

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


2 years ago
#3

  • Keywords has-patch added; needs-patch removed

This adds a check to the create/add user to blog screen to match and allow only the roles that are displayed in the UI.

#4 @spacedmonkey
2 years ago

  • Milestone Awaiting Review6.7
  • Owner set to ideag
  • Status newassigned

#5 @peterwilsoncc
2 years ago

  • Component Networks and SitesUsers
  • Version 4.9.42.8

I've added some notes to the linked pull request but agree this would be helpful to get in to WordPress 6.7.

I've set the version to 2.8 as that's when get_editable_roles() and the associated filter were introduced. It could be argued that it should be 3.0 as that's when Multisite was merged in to WordPress Core but let's not bikeshed it too much :)

#6 @peterwilsoncc
22 months ago

  • Keywords changes-requested added
  • Milestone 6.76.8

I've moved this off the milestone as there are some change requests on the PR that will need to be followed up prior to commit.

#8 @peterwilsoncc
17 months ago

  • Keywords commit added; changes-requested removed

The follow up PR implements the changes suggested in the original, thanks @sukhendu2002, so I think this is good to go in.

#9 @ideag
17 months ago

Can I please be removed from this ticket? Thank you!

#10 @peterwilsoncc
17 months ago

  • Owner changed from ideag to peterwilsoncc

@ideag I've assigned myself as the owner your place. I don't think I can block you from receiving notifications about this ticket but I'm about to commit the code so there shouldn't be too many more emails.

#11 @peterwilsoncc
17 months ago

  • Resolutionfixed
  • Status assignedclosed

In 59901:

Users: Use editable_roles filter for multisite sub-sites.

Adds a check of the editable_roles filter when adding users to a multisite sub-site to ensure the role is permitted to be used on the network. If the role is blocked by the filter, attempting to add the role will trigger a wp_die() similar to attempting to add a user with the role on a single site install.

Props eartboard, hareesh-pillai, ideag, sukhendu2002, spacedmonkey, thomaswm.
Fixes #43251.

#12 @ideag
17 months ago

I am not concerned about the emails. I do want to avoid receiving props for this one.

#13 @peterwilsoncc
17 months ago

@ideag I've removed your credit from the system, as discussed.

#14 @ideag
17 months ago

Thank you!

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


16 months ago

Note: See TracTickets for help on using tickets.