Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/wp-admin/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,18 @@
wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 );
}

// The new role of the current user must also have the promote_users cap or be a multisite super admin.
if ( $id === $current_user->ID
&& ! $wp_roles->role_objects[ $role ]->has_cap( 'promote_users' )
&& ! ( is_multisite() && current_user_can( 'manage_network_users' ) )
) {
$update = 'err_admin_role';
// The new role of the current user must also have the promote_users cap, be a multisite super admin and not be empty.
if ( $id === $current_user->ID ) {
if ( '' === $role ) {
wp_die( __( 'Sorry, you cannot remove your own role.' ), 403 );
}

if ( $wp_roles->role_objects[ $role ]->has_cap( 'promote_users' ) || ( is_multisite() && current_user_can( 'manage_network_users' ) ) ) {
continue;
}

$update = 'err_admin_role';
continue;
}

// If the user doesn't already belong to the blog, bail.
Expand Down
Loading