WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/27/2015 07:10:08 PM (6 years ago)
Author:
wonderboymusic
Message:

Users List Table: show the "Change role to" dropdown on the top and bottom. Currently only shows on top.

See #27743.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/users.php

    r34393 r34636  
    9696
    9797    $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 ( ! empty( $_REQUEST['new_role2'] ) ) {
     100        $role = $_REQUEST['new_role2'];
     101    } elseif ( ! empty( $_REQUEST['new_role'] ) ) {
     102        $role = $_REQUEST['new_role'];
     103    }
     104
     105    if ( ! $role || empty( $editable_roles[ $role ] ) ) {
     106        wp_die( __( 'You can’t give users that role.' ) );
     107    }
    100108
    101109    $userids = $_REQUEST['users'];
     
    107115            wp_die(__('You can’t edit that user.'));
    108116        // 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')
    110118            && ! ( is_multisite() && is_super_admin() ) ) {
    111119                $update = 'err_admin_role';
     
    123131
    124132        $user = get_userdata( $id );
    125         $user->set_role($_REQUEST['new_role']);
     133        $user->set_role( $role );
    126134    }
    127135
Note: See TracChangeset for help on using the changeset viewer.