File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 143143 wp_die ( __ ( 'Sorry, you are not allowed to edit this user. ' ), 403 );
144144 }
145145
146- // The new role of the current user must also have the promote_users cap or be a multisite super admin.
147- if ( $ id === $ current_user ->ID
148- && ! $ wp_roles ->role_objects [ $ role ]->has_cap ( 'promote_users ' )
149- && ! ( is_multisite () && current_user_can ( 'manage_network_users ' ) )
150- ) {
151- $ update = 'err_admin_role ' ;
146+ // The new role of the current user must also have the promote_users cap, be a multisite super admin and not be empty.
147+ if ( $ id === $ current_user ->ID ) {
148+ if ( '' === $ role ) {
149+ wp_die ( __ ( 'Sorry, you cannot remove your own role. ' ), 403 );
150+ }
151+
152+ if ( $ wp_roles ->role_objects [ $ role ]->has_cap ( 'promote_users ' ) || ( is_multisite () && current_user_can ( 'manage_network_users ' ) ) ) {
152153 continue ;
154+ }
155+
156+ $ update = 'err_admin_role ' ;
157+ continue ;
153158 }
154159
155160 // If the user doesn't already belong to the blog, bail.
You can’t perform that action at this time.
0 commit comments