WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#18164 closed defect (bug) (fixed)

Users with capes don't need promote_users on their new role

Reported by: nacin Owned by: nacin
Milestone: 3.3 Priority: normal
Severity: normal Version:
Component: Network Admin Keywords: has-patch
Focuses: multisite Cc:

Description

When setting your own role:

		// The new role of the current user must also have promote_users caps
		if ( $id == $current_user->ID && !$wp_roles->role_objects[$_REQUEST['new_role']]->has_cap('promote_users') ) {
			$update = 'err_admin_role';
			continue;
		}

There's no reason to prevent a super admin from demoting themselves on a site.

Attachments (2)

18164.diff (793 bytes) - added by fonglh 2 years ago.
18164.2.diff (792 bytes) - added by fonglh 2 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 johnbillion3 years ago

How does one get a cape?

comment:2 zippykid3 years ago

Step 1 - Visit http://www.forevergeek.com/2010/04/buy_your_capes_online_/

Step 2 - Add cape to cart

Step 3 - Go through check out procedure

Step 4 - Wait for delivery truck

Step 5 - Receive and Open package - find out it's shoes your wife ordered, go back outside to wait for delivery truck

Step 6 - Receive package - open - find cape

Step 7 - Wear cape.

Step 8 - Commence core hacking.

Version 0, edited 3 years ago by zippykid (next)

comment:3 fonglh2 years ago

  • Keywords has-patch added

Checks for cape before deciding if user can demote himself.

comment:4 nacin2 years ago

The more generic is_super_admin() would probably be a better fit here.

fonglh2 years ago

fonglh2 years ago

comment:5 fonglh2 years ago

Thanks for the tip! I've updated the patch to use is_super_admin()

comment:6 nacin2 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [19024]:

Allow a super admin to demote themselves on a site to a role that does not contain the promote_users cap. props fonglh, fixes #18164.

comment:7 nacin2 years ago

Thanks for the patch, fonglh!

comment:8 fonglh2 years ago

No problem! Glad to have been able to make my first contribution to core.

Note: See TracTickets for help on using tickets.