Make WordPress Core

Changeset 2995


Ignore:
Timestamp:
11/06/2005 03:58:52 AM (19 years ago)
Author:
ryan
Message:

Show Role in profile and user edit. Don't allow users with edit_users caps to demote themselves. Props: davidhouse, ringmaster. fixes #1825

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r2979 r2995  
    257257
    258258function edit_user($user_id = 0) {
     259    global $current_user, $wp_roles;
    259260
    260261    if ($user_id != 0) {
     
    277278        $pass2 = $_POST['pass2'];
    278279
     280    if (isset ($_POST['role'])) {
     281        if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users'))
     282            $user->role = $_POST['role'];
     283    }
     284
     285    if (isset ($_POST['role'])) {
     286        $user->role = $_POST['role'];
     287    }
    279288    if (isset ($_POST['email']))
    280289        $user->user_email = wp_specialchars(trim($_POST['email']));
  • trunk/wp-admin/profile.php

    r2994 r2995  
    3131<input type="text" name="user_login" value="<?php echo $profiledata->user_login; ?>" disabled="disabled" />
    3232</label></p>
     33
     34<p><label><?php _e('Role: (no editing)') ?><br />
     35<input type="text" name="role" value="<?php echo $wp_roles->role_names[$profileuser->roles[0]] ?>" disabled="disabled" /></label></p>
     36
    3337<p><label><?php _e('First name:') ?><br />
    3438<input type="text" name="first_name" value="<?php echo $profiledata->first_name ?>" /></label></p>
  • trunk/wp-admin/user-edit.php

    r2889 r2995  
    8383<input type="text" name="user_login" value="<?php echo $profiledata->user_login; ?>" disabled="disabled" />
    8484</label></p>
     85
     86<p><label><?php _e('Role:') ?><br />
     87<?php
     88// print_r($profileuser);
     89echo '<select name="role">';
     90foreach($wp_roles->role_names as $role => $name) {
     91    $selected = ($profileuser->roles[0] == $role) ? ' selected="selected"' : '';
     92    echo "<option value=\"{$role}\"{$selected}>{$name}</option>";
     93}
     94echo '</select>';
     95?></label></p>
     96
    8597<p><label><?php _e('First name:') ?><br />
    8698<input type="text" name="first_name" value="<?php echo $profiledata->first_name ?>" /></label></p>
  • trunk/wp-includes/registration-functions.php

    r2994 r2995  
    6060    update_usermeta( $user_id, 'aim', $aim );
    6161    update_usermeta( $user_id, 'yim', $yim );
    62    
     62
     63    if ($update && !empty($role)) {
     64        $user = new WP_User($user_id);
     65        $user->set_role($role);
     66    }
     67
    6368    if ( !$update ) {
    6469        $user = new WP_User($user_id);
Note: See TracChangeset for help on using the changeset viewer.