| 1 |
<?php |
|---|
| 2 |
require_once('admin.php'); |
|---|
| 3 |
|
|---|
| 4 |
$title = __('Edit User'); |
|---|
| 5 |
$parent_file = 'profile.php'; |
|---|
| 6 |
$submenu_file = 'users.php'; |
|---|
| 7 |
|
|---|
| 8 |
$wpvarstoreset = array('action', 'redirect', 'profile', 'user_id'); |
|---|
| 9 |
for ($i=0; $i<count($wpvarstoreset); $i += 1) { |
|---|
| 10 |
$wpvar = $wpvarstoreset[$i]; |
|---|
| 11 |
if (!isset($$wpvar)) { |
|---|
| 12 |
if (empty($_POST["$wpvar"])) { |
|---|
| 13 |
if (empty($_GET["$wpvar"])) { |
|---|
| 14 |
$$wpvar = ''; |
|---|
| 15 |
} else { |
|---|
| 16 |
$$wpvar = $_GET["$wpvar"]; |
|---|
| 17 |
} |
|---|
| 18 |
} else { |
|---|
| 19 |
$$wpvar = $_POST["$wpvar"]; |
|---|
| 20 |
} |
|---|
| 21 |
} |
|---|
| 22 |
} |
|---|
| 23 |
|
|---|
| 24 |
switch ($action) { |
|---|
| 25 |
case 'switchposts': |
|---|
| 26 |
|
|---|
| 27 |
check_admin_referer(); |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
break; |
|---|
| 32 |
|
|---|
| 33 |
case 'update': |
|---|
| 34 |
|
|---|
| 35 |
check_admin_referer(); |
|---|
| 36 |
|
|---|
| 37 |
$errors = array(); |
|---|
| 38 |
|
|---|
| 39 |
if (!current_user_can('edit_users')) |
|---|
| 40 |
$errors['head'] = __('You do not have permission to edit this user.'); |
|---|
| 41 |
else |
|---|
| 42 |
$errors = edit_user($user_id); |
|---|
| 43 |
|
|---|
| 44 |
if(count($errors) == 0) { |
|---|
| 45 |
header("Location: user-edit.php?user_id=$user_id&updated=true"); |
|---|
| 46 |
exit; |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
default: |
|---|
| 50 |
include ('admin-header.php'); |
|---|
| 51 |
|
|---|
| 52 |
$profileuser = new WP_User($user_id); |
|---|
| 53 |
|
|---|
| 54 |
if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permission to edit this user.'); |
|---|
| 55 |
?> |
|---|
| 56 |
|
|---|
| 57 |
<?php if ( isset($_GET['updated']) ) : ?> |
|---|
| 58 |
<div id="message" class="updated fade"> |
|---|
| 59 |
<p><strong><?php _e('User updated.') ?></strong></p> |
|---|
| 60 |
</div> |
|---|
| 61 |
<?php endif; ?> |
|---|
| 62 |
<?php if ( count($errors) != 0 ) : ?> |
|---|
| 63 |
<div class="error"> |
|---|
| 64 |
<ul> |
|---|
| 65 |
<?php |
|---|
| 66 |
foreach($errors as $error) echo "<li>$error</li>"; |
|---|
| 67 |
?> |
|---|
| 68 |
</ul> |
|---|
| 69 |
</div> |
|---|
| 70 |
<?php endif; ?> |
|---|
| 71 |
|
|---|
| 72 |
<?php if (!current_user_can('edit_users')) { include('admin-footer.php'); die(); } ?> |
|---|
| 73 |
|
|---|
| 74 |
<div class="wrap"> |
|---|
| 75 |
<h2><?php _e('Edit User'); ?></h2> |
|---|
| 76 |
|
|---|
| 77 |
<form name="profile" id="your-profile" action="user-edit.php" method="post"> |
|---|
| 78 |
<p> |
|---|
| 79 |
<input type="hidden" name="from" value="profile" /> |
|---|
| 80 |
<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" /> |
|---|
| 81 |
</p> |
|---|
| 82 |
|
|---|
| 83 |
<fieldset> |
|---|
| 84 |
<legend><?php _e('Name'); ?></legend> |
|---|
| 85 |
<p><label><?php _e('Username: (no editing)'); ?><br /> |
|---|
| 86 |
<input type="text" name="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" /> |
|---|
| 87 |
</label></p> |
|---|
| 88 |
|
|---|
| 89 |
<p><label><?php _e('Role:') ?><br /> |
|---|
| 90 |
<?php |
|---|
| 91 |
|
|---|
| 92 |
echo '<select name="role">'; |
|---|
| 93 |
foreach($wp_roles->role_names as $role => $name) { |
|---|
| 94 |
$selected = ($profileuser->has_cap($role)) ? ' selected="selected"' : ''; |
|---|
| 95 |
echo "<option value=\"{$role}\"{$selected}>{$name}</option>"; |
|---|
| 96 |
} |
|---|
| 97 |
echo '</select>'; |
|---|
| 98 |
?></label></p> |
|---|
| 99 |
|
|---|
| 100 |
<p><label><?php _e('First name:') ?><br /> |
|---|
| 101 |
<input type="text" name="first_name" value="<?php echo $profileuser->first_name ?>" /></label></p> |
|---|
| 102 |
|
|---|
| 103 |
<p><label><?php _e('Last name:') ?><br /> |
|---|
| 104 |
<input type="text" name="last_name" value="<?php echo $profileuser->last_name ?>" /></label></p> |
|---|
| 105 |
|
|---|
| 106 |
<p><label><?php _e('Nickname:') ?><br /> |
|---|
| 107 |
<input type="text" name="nickname" value="<?php echo $profileuser->nickname ?>" /></label></p> |
|---|
| 108 |
|
|---|
| 109 |
</p><label><?php _e('Display name publicly as:') ?> <br /> |
|---|
| 110 |
<select name="display_name"> |
|---|
| 111 |
<option value="<?php echo $profileuser->display_name; ?>"><?php echo $profileuser->display_name; ?></option> |
|---|
| 112 |
<option value="<?php echo $profileuser->nickname ?>"><?php echo $profileuser->nickname ?></option> |
|---|
| 113 |
<option value="<?php echo $profileuser->user_login ?>"><?php echo $profileuser->user_login ?></option> |
|---|
| 114 |
<?php if ( !empty( $profileuser->first_name ) ) : ?> |
|---|
| 115 |
<option value="<?php echo $profileuser->first_name ?>"><?php echo $profileuser->first_name ?></option> |
|---|
| 116 |
<?php endif; ?> |
|---|
| 117 |
<?php if ( !empty( $profileuser->last_name ) ) : ?> |
|---|
| 118 |
<option value="<?php echo $profileuser->last_name ?>"><?php echo $profileuser->last_name ?></option> |
|---|
| 119 |
<?php endif; ?> |
|---|
| 120 |
<?php if ( !empty( $profileuser->first_name ) && !empty( $profileuser->last_name ) ) : ?> |
|---|
| 121 |
<option value="<?php echo $profileuser->first_name." ".$profileuser->last_name ?>"><?php echo $profileuser->first_name." ".$profileuser->last_name ?></option> |
|---|
| 122 |
<option value="<?php echo $profileuser->last_name." ".$profileuser->first_name ?>"><?php echo $profileuser->last_name." ".$profileuser->first_name ?></option> |
|---|
| 123 |
<?php endif; ?> |
|---|
| 124 |
</select></label></p> |
|---|
| 125 |
</fieldset> |
|---|
| 126 |
|
|---|
| 127 |
<fieldset> |
|---|
| 128 |
<legend><?php _e('Contact Info'); ?></legend> |
|---|
| 129 |
|
|---|
| 130 |
<p><label><?php _e('E-mail: (required)') ?><br /> |
|---|
| 131 |
<input type="text" name="email" value="<?php echo $profileuser->user_email ?>" /></label></p> |
|---|
| 132 |
|
|---|
| 133 |
<p><label><?php _e('Website:') ?><br /> |
|---|
| 134 |
<input type="text" name="url" value="<?php echo $profileuser->user_url ?>" /> |
|---|
| 135 |
</label></p> |
|---|
| 136 |
|
|---|
| 137 |
<p><label><?php _e('AIM:') ?><br /> |
|---|
| 138 |
<input type="text" name="aim" value="<?php echo $profileuser->aim ?>" /> |
|---|
| 139 |
</label></p> |
|---|
| 140 |
|
|---|
| 141 |
<p><label><?php _e('Yahoo IM:') ?><br /> |
|---|
| 142 |
<input type="text" name="yim" value="<?php echo $profileuser->yim ?>" /> |
|---|
| 143 |
</label></p> |
|---|
| 144 |
|
|---|
| 145 |
<p><label><?php _e('Jabber / Google Talk:') ?> |
|---|
| 146 |
<input type="text" name="jabber" value="<?php echo $profileuser->jabber ?>" /></label> |
|---|
| 147 |
</p> |
|---|
| 148 |
</fieldset> |
|---|
| 149 |
<br clear="all" /> |
|---|
| 150 |
<fieldset> |
|---|
| 151 |
<legend><?php _e('About the user'); ?></legend> |
|---|
| 152 |
<p class="desc"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p> |
|---|
| 153 |
<p><textarea name="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea></p> |
|---|
| 154 |
</fieldset> |
|---|
| 155 |
|
|---|
| 156 |
<?php |
|---|
| 157 |
$show_password_fields = apply_filters('show_password_fields', true); |
|---|
| 158 |
if ( $show_password_fields ) : |
|---|
| 159 |
?> |
|---|
| 160 |
<fieldset> |
|---|
| 161 |
<legend><?php _e("Update User's Password"); ?></legend> |
|---|
| 162 |
<p class="desc"><?php _e("If you would like to change the user's password type a new one twice below. Otherwise leave this blank."); ?></p> |
|---|
| 163 |
<p><label><?php _e('New Password:'); ?><br /> |
|---|
| 164 |
<input type="password" name="pass1" size="16" value="" /> |
|---|
| 165 |
</label></p> |
|---|
| 166 |
<p><label><?php _e('Type it one more time:'); ?><br /> |
|---|
| 167 |
<input type="password" name="pass2" size="16" value="" /> |
|---|
| 168 |
</label></p> |
|---|
| 169 |
</fieldset> |
|---|
| 170 |
<?php endif; ?> |
|---|
| 171 |
|
|---|
| 172 |
<?php do_action('edit_user_profile'); ?> |
|---|
| 173 |
|
|---|
| 174 |
<br clear="all" /> |
|---|
| 175 |
<table width="99%" border="0" cellspacing="2" cellpadding="3" class="editform"> |
|---|
| 176 |
<?php |
|---|
| 177 |
if(count($profileuser->caps) > count($profileuser->roles)): |
|---|
| 178 |
?> |
|---|
| 179 |
<tr> |
|---|
| 180 |
<th scope="row"><?php _e('Additional Capabilities:') ?></th> |
|---|
| 181 |
<td><?php |
|---|
| 182 |
$output = ''; |
|---|
| 183 |
foreach($profileuser->caps as $cap => $value) { |
|---|
| 184 |
if(!$wp_roles->is_role($cap)) { |
|---|
| 185 |
if($output != '') $output .= ', '; |
|---|
| 186 |
$output .= $value ? $cap : "Denied: {$cap}"; |
|---|
| 187 |
} |
|---|
| 188 |
} |
|---|
| 189 |
echo $output; |
|---|
| 190 |
?></td> |
|---|
| 191 |
</tr> |
|---|
| 192 |
<?php |
|---|
| 193 |
endif; |
|---|
| 194 |
?> |
|---|
| 195 |
</table> |
|---|
| 196 |
<p class="submit"> |
|---|
| 197 |
<input type="hidden" name="action" value="update" /> |
|---|
| 198 |
<input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" /> |
|---|
| 199 |
<input type="submit" value="<?php _e('Update User »') ?>" name="submit" /> |
|---|
| 200 |
</p> |
|---|
| 201 |
</form> |
|---|
| 202 |
</div> |
|---|
| 203 |
<?php |
|---|
| 204 |
break; |
|---|
| 205 |
} |
|---|
| 206 |
|
|---|
| 207 |
include('admin-footer.php'); |
|---|
| 208 |
?> |
|---|
| 209 |
|
|---|