Better handling of users with no role. Props Mark Jaquith. #2809

git-svn-id: http://svn.automattic.com/wordpress/trunk@3859 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2006-06-10 20:26:26 +00:00
parent 5e7c850484
commit 8310e71be6
4 changed files with 26 additions and 7 deletions

View File

@@ -103,11 +103,22 @@ if ( !current_user_can('edit_user', $user_id) )
<?php
// print_r($profileuser);
echo '<select name="role">';
$role_list = '';
$user_has_role = false;
foreach($wp_roles->role_names as $role => $name) {
$selected = ($profileuser->has_cap($role)) ? ' selected="selected"' : '';
echo "<option value=\"{$role}\"{$selected}>{$name}</option>";
if ( $profileuser->has_cap($role) ) {
$selected = ' selected="selected"';
$user_has_role = true;
} else {
$selected = '';
}
$role_list .= "<option value=\"{$role}\"{$selected}>{$name}</option>";
}
echo '</select>';
if ( $user_has_role )
$role_list .= '<option value="">' . __('&mdash; No role for this blog &mdash;') . '</option>';
else
$role_list .= '<option value="" selected="selected">' . __('&mdash; No role for this blog &mdash;') . '</option>';
echo $role_list . '</select>';
?></label></p>
<p><label><?php _e('First name:') ?><br />

View File

@@ -313,7 +313,11 @@ foreach($roleclasses as $role => $roleclass) {
?>
<tr>
<?php if ( !empty($role) ) : ?>
<th colspan="7" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>
<?php else : ?>
<th colspan="7" align="left"><h3><em><?php _e('No role for this blog'); ?></h3></th>
<?php endif; ?>
</tr>
<tr class="thead">
<th style="text-align: left"><?php _e('ID') ?></th>