Make WordPress Core


Ignore:
Timestamp:
01/06/2009 05:23:11 PM (16 years ago)
Author:
ryan
Message:

use wp_dropdown_roles(). Props jeremyclarke. fixes #8764

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/user-edit.php

    r10150 r10319  
    246246<?php if ( !$is_profile_page ): ?>
    247247<tr><th><label for="role"><?php _e('Role:') ?></label></th>
    248 <?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 )
     248<td><select name="role" id="role">
     249<?php
     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; ?>
     263
     264echo $role_list;?>
     265</select></td></tr>
     266<?php endif; //!$is_profile_page ?>
    270267
    271268<tr>
Note: See TracChangeset for help on using the changeset viewer.