Make WordPress Core

Ticket #8764: user-edit_use_wp_dropdown_roles.diff

File user-edit_use_wp_dropdown_roles.diff, 1.7 KB (added by jeremyclarke, 15 years ago)

use wp_dropdown_roles in user-edit.php

  • wp-admin/user-edit.php

     
    245245
    246246<?php if ( !$is_profile_page ): ?>
    247247<tr><th><label for="role"><?php _e('Role:') ?></label></th>
     248<td><select name="role" id="role">
    248249<?php
    249 // print_r($profileuser);
    250 echo '<td><select name="role" id="role">';
    251 $role_list = '';
    252 $user_has_role = false;
    253 foreach($wp_roles->role_names as $role => $name) {
    254         $name = translate_with_context($name);
    255         if ( $profileuser->has_cap($role) ) {
    256                 $selected = ' selected="selected"';
    257                 $user_has_role = true;
    258         } else {
    259                 $selected = '';
    260         }
    261         $role_list .= "<option value=\"{$role}\"{$selected}>{$name}</option>";
    262 }
    263 if ( $user_has_role )
     250// Get the highest/primary role for this user
     251// TODO: create a function that does this: wp_get_user_role()
     252$user_roles = $profileuser->roles;
     253$user_role = array_shift($user_roles);
     254
     255// print the full list of roles with the primary one selected.
     256wp_dropdown_roles($user_role);
     257
     258// print the 'no role' option. Make it selected if the user has no role yet.
     259if ( $user_role )
    264260        $role_list .= '<option value="">' . __('&mdash; No role for this blog &mdash;') . '</option>';
    265261else
    266262        $role_list .= '<option value="" selected="selected">' . __('&mdash; No role for this blog &mdash;') . '</option>';
    267 echo $role_list . '</select></td></tr>';
    268 ?>
    269 <?php endif; ?>
    270263
     264echo $role_list;?>
     265</select></td></tr>
     266<?php endif; //!$is_profile_page ?>
     267
    271268<tr>
    272269        <th><label for="first_name"><?php _e('First name') ?></label></th>
    273270        <td><input type="text" name="first_name" id="first_name" value="<?php echo $profileuser->first_name ?>" class="regular-text" /></td>