Ticket #27743: 27743.2.diff
File 27743.2.diff, 2.8 KB (added by , 8 years ago) |
---|
-
src/wp-admin/includes/class-wp-users-list-table.php
214 214 * or below the table ("bottom"). 215 215 */ 216 216 protected function extra_tablenav( $which ) { 217 if ( 'top' != $which ) 218 return; 217 $id = 'bottom' === $which ? 'new_role2' : 'new_role'; 219 218 ?> 220 219 <div class="alignleft actions"> 221 220 <?php if ( current_user_can( 'promote_users' ) ) : ?> 222 <label class="screen-reader-text" for=" new_role"><?php _e( 'Change role to…' ) ?></label>223 <select name=" new_role" id="new_role">221 <label class="screen-reader-text" for="<?php echo $id ?>"><?php _e( 'Change role to…' ) ?></label> 222 <select name="<?php echo $id ?>" id="<?php echo $id ?>"> 224 223 <option value=""><?php _e( 'Change role to…' ) ?></option> 225 224 <?php wp_dropdown_roles(); ?> 226 225 </select> … … 250 249 * @return string The bulk action required. 251 250 */ 252 251 public function current_action() { 253 if ( isset($_REQUEST['changeit']) && !empty($_REQUEST['new_role']) ) 252 if ( isset( $_REQUEST['changeit'] ) && 253 ( ! empty( $_REQUEST['new_role'] ) || ! empty( $_REQUEST['new_role2'] ) ) ) { 254 254 return 'promote'; 255 } 255 256 256 257 return parent::current_action(); 257 258 } -
src/wp-admin/users.php
95 95 } 96 96 97 97 $editable_roles = get_editable_roles(); 98 if ( empty( $editable_roles[$_REQUEST['new_role']] ) ) 99 wp_die(__('You can’t give users that role.')); 98 $role = false; 99 if ( isset( $_REQUEST['new_role'] ) ) { 100 $role = $_REQUEST['new_role']; 101 } elseif ( isset( $_REQUEST['new_role2'] ) ) { 102 $role = $_REQUEST['new_role2']; 103 } 100 104 105 if ( ! $role || empty( $editable_roles[ $role ] ) ) { 106 wp_die( __( 'You can’t give users that role.' ) ); 107 } 108 101 109 $userids = $_REQUEST['users']; 102 110 $update = 'promote'; 103 111 foreach ( $userids as $id ) { … … 106 114 if ( ! current_user_can('promote_user', $id) ) 107 115 wp_die(__('You can’t edit that user.')); 108 116 // The new role of the current user must also have the promote_users cap or be a multisite super admin 109 if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $ _REQUEST['new_role']]->has_cap('promote_users')117 if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $role ]->has_cap('promote_users') 110 118 && ! ( is_multisite() && is_super_admin() ) ) { 111 119 $update = 'err_admin_role'; 112 120 continue; … … 122 130 } 123 131 124 132 $user = get_userdata( $id ); 125 $user->set_role( $_REQUEST['new_role']);133 $user->set_role( $role ); 126 134 } 127 135 128 136 wp_redirect(add_query_arg('update', $update, $redirect));