mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Edit user administration panel.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** WordPress Administration Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 if ( defined('IS_PROFILE_PAGE') && IS_PROFILE_PAGE )
mp-wp_genesis 13 $is_profile_page = true;
mp-wp_genesis 14 else
mp-wp_genesis 15 $is_profile_page = false;
mp-wp_genesis 16
mp-wp_genesis 17 $title = $is_profile_page? __('Profile') : __('Edit User');
mp-wp_genesis 18 if ( current_user_can('edit_users') && !$is_profile_page )
mp-wp_genesis 19 $submenu_file = 'users.php';
mp-wp_genesis 20 else
mp-wp_genesis 21 $submenu_file = 'profile.php';
mp-wp_genesis 22 $parent_file = 'users.php';
mp-wp_genesis 23
mp-wp_genesis 24 wp_reset_vars(array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer'));
mp-wp_genesis 25
mp-wp_genesis 26 $wp_http_referer = remove_query_arg(array('update', 'delete_count'), stripslashes($wp_http_referer));
mp-wp_genesis 27
mp-wp_genesis 28 $user_id = (int) $user_id;
mp-wp_genesis 29
mp-wp_genesis 30 if ( !$user_id ) {
mp-wp_genesis 31 if ( $is_profile_page ) {
mp-wp_genesis 32 $current_user = wp_get_current_user();
mp-wp_genesis 33 $user_id = $current_user->ID;
mp-wp_genesis 34 } else {
mp-wp_genesis 35 wp_die(__('Invalid user ID.'));
mp-wp_genesis 36 }
mp-wp_genesis 37 } elseif ( !get_userdata($user_id) ) {
mp-wp_genesis 38 wp_die( __('Invalid user ID.') );
mp-wp_genesis 39 }
mp-wp_genesis 40
mp-wp_genesis 41 /**
mp-wp_genesis 42 * Optional SSL preference that can be turned on by hooking to the 'personal_options' action.
mp-wp_genesis 43 *
mp-wp_genesis 44 * @since 2.7.0
mp-wp_genesis 45 *
mp-wp_genesis 46 * @param object $user User data object
mp-wp_genesis 47 */
mp-wp_genesis 48 function use_ssl_preference($user) {
mp-wp_genesis 49 ?>
mp-wp_genesis 50 <tr>
mp-wp_genesis 51 <th scope="row"><?php _e('Use https')?></th>
mp-wp_genesis 52 <td><label for="use_ssl"><input name="use_ssl" type="checkbox" id="use_ssl" value="1" <?php checked('1', $user->use_ssl); ?> /> <?php _e('Always use https when visiting the admin'); ?></label></td>
mp-wp_genesis 53 </tr>
mp-wp_genesis 54 <?php
mp-wp_genesis 55 }
mp-wp_genesis 56
mp-wp_genesis 57 switch ($action) {
mp-wp_genesis 58 case 'switchposts':
mp-wp_genesis 59
mp-wp_genesis 60 check_admin_referer();
mp-wp_genesis 61
mp-wp_genesis 62 /* TODO: Switch all posts from one user to another user */
mp-wp_genesis 63
mp-wp_genesis 64 break;
mp-wp_genesis 65
mp-wp_genesis 66 case 'update':
mp-wp_genesis 67
mp-wp_genesis 68 check_admin_referer('update-user_' . $user_id);
mp-wp_genesis 69
mp-wp_genesis 70 if ( !current_user_can('edit_user', $user_id) )
mp-wp_genesis 71 wp_die(__('You do not have permission to edit this user.'));
mp-wp_genesis 72
mp-wp_genesis 73 if ($is_profile_page)
mp-wp_genesis 74 do_action('personal_options_update');
mp-wp_genesis 75 else
mp-wp_genesis 76 do_action('edit_user_profile_update');
mp-wp_genesis 77
mp-wp_genesis 78 $errors = edit_user($user_id);
mp-wp_genesis 79
mp-wp_genesis 80 if ( !is_wp_error( $errors ) ) {
mp-wp_genesis 81 $redirect = ($is_profile_page? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
mp-wp_genesis 82 $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
mp-wp_genesis 83 wp_redirect($redirect);
mp-wp_genesis 84 exit;
mp-wp_genesis 85 }
mp-wp_genesis 86
mp-wp_genesis 87 default:
mp-wp_genesis 88 $profileuser = get_user_to_edit($user_id);
mp-wp_genesis 89
mp-wp_genesis 90 if ( !current_user_can('edit_user', $user_id) )
mp-wp_genesis 91 wp_die(__('You do not have permission to edit this user.'));
mp-wp_genesis 92
mp-wp_genesis 93 include ('admin-header.php');
mp-wp_genesis 94 ?>
mp-wp_genesis 95
mp-wp_genesis 96 <?php if ( isset($_GET['updated']) ) : ?>
mp-wp_genesis 97 <div id="message" class="updated fade">
mp-wp_genesis 98 <p><strong><?php _e('User updated.') ?></strong></p>
mp-wp_genesis 99 <?php if ( $wp_http_referer && !$is_profile_page ) : ?>
mp-wp_genesis 100 <p><a href="users.php"><?php _e('← Back to Authors and Users'); ?></a></p>
mp-wp_genesis 101 <?php endif; ?>
mp-wp_genesis 102 </div>
mp-wp_genesis 103 <?php endif; ?>
mp-wp_genesis 104 <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
mp-wp_genesis 105 <div class="error">
mp-wp_genesis 106 <ul>
mp-wp_genesis 107 <?php
mp-wp_genesis 108 foreach( $errors->get_error_messages() as $message )
mp-wp_genesis 109 echo "<li>$message</li>";
mp-wp_genesis 110 ?>
mp-wp_genesis 111 </ul>
mp-wp_genesis 112 </div>
mp-wp_genesis 113 <?php endif; ?>
mp-wp_genesis 114
mp-wp_genesis 115 <div class="wrap" id="profile-page">
mp-wp_genesis 116 <?php screen_icon(); ?>
mp-wp_genesis 117 <h2><?php echo wp_specialchars( $title ); ?></h2>
mp-wp_genesis 118
mp-wp_genesis 119 <form id="your-profile" action="" method="post">
mp-wp_genesis 120 <?php wp_nonce_field('update-user_' . $user_id) ?>
mp-wp_genesis 121 <?php if ( $wp_http_referer ) : ?>
mp-wp_genesis 122 <input type="hidden" name="wp_http_referer" value="<?php echo clean_url($wp_http_referer); ?>" />
mp-wp_genesis 123 <?php endif; ?>
mp-wp_genesis 124 <p>
mp-wp_genesis 125 <input type="hidden" name="from" value="profile" />
mp-wp_genesis 126 <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
mp-wp_genesis 127 </p>
mp-wp_genesis 128
mp-wp_genesis 129 <h3><?php _e('Personal Options'); ?></h3>
mp-wp_genesis 130
mp-wp_genesis 131 <table class="form-table">
mp-wp_genesis 132 <tr>
mp-wp_genesis 133 <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
mp-wp_genesis 134 <td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( !empty($profileuser->comment_shortcuts) ) checked('true', $profileuser->comment_shortcuts); ?> /> <?php _e( 'Enable keyboard shortcuts for comment moderation. <a href="http://codex.wordpress.org/Keyboard_Shortcuts">More information</a>' ); ?></label></td>
mp-wp_genesis 135 </tr>
mp-wp_genesis 136 <?php
mp-wp_genesis 137 do_action('personal_options', $profileuser);
mp-wp_genesis 138 ?>
mp-wp_genesis 139 </table>
mp-wp_genesis 140 <?php
mp-wp_genesis 141 if ( $is_profile_page )
mp-wp_genesis 142 do_action('profile_personal_options', $profileuser);
mp-wp_genesis 143 ?>
mp-wp_genesis 144
mp-wp_genesis 145 <h3><?php _e('Name') ?></h3>
mp-wp_genesis 146
mp-wp_genesis 147 <table class="form-table">
mp-wp_genesis 148 <tr>
mp-wp_genesis 149 <th><label for="user_login"><?php _e('Username'); ?></label></th>
mp-wp_genesis 150 <td><input type="text" name="user_login" id="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" class="regular-text" /> <?php _e('Your username cannot be changed.'); ?></td>
mp-wp_genesis 151 </tr>
mp-wp_genesis 152
mp-wp_genesis 153 <?php if ( !$is_profile_page ): ?>
mp-wp_genesis 154 <tr><th><label for="role"><?php _e('Role:') ?></label></th>
mp-wp_genesis 155 <?php
mp-wp_genesis 156 // print_r($profileuser);
mp-wp_genesis 157 echo '<td><select name="role" id="role">';
mp-wp_genesis 158 $role_list = '';
mp-wp_genesis 159 $user_has_role = false;
mp-wp_genesis 160 foreach($wp_roles->role_names as $role => $name) {
mp-wp_genesis 161 $name = translate_with_context($name);
mp-wp_genesis 162 if ( $profileuser->has_cap($role) ) {
mp-wp_genesis 163 $selected = ' selected="selected"';
mp-wp_genesis 164 $user_has_role = true;
mp-wp_genesis 165 } else {
mp-wp_genesis 166 $selected = '';
mp-wp_genesis 167 }
mp-wp_genesis 168 $role_list .= "<option value=\"{$role}\"{$selected}>{$name}</option>";
mp-wp_genesis 169 }
mp-wp_genesis 170 if ( $user_has_role )
mp-wp_genesis 171 $role_list .= '<option value="">' . __('— No role for this blog —') . '</option>';
mp-wp_genesis 172 else
mp-wp_genesis 173 $role_list .= '<option value="" selected="selected">' . __('— No role for this blog —') . '</option>';
mp-wp_genesis 174 echo $role_list . '</select></td></tr>';
mp-wp_genesis 175 ?>
mp-wp_genesis 176 <?php endif; ?>
mp-wp_genesis 177
mp-wp_genesis 178 <tr>
mp-wp_genesis 179 <th><label for="first_name"><?php _e('First name') ?></label></th>
mp-wp_genesis 180 <td><input type="text" name="first_name" id="first_name" value="<?php echo $profileuser->first_name ?>" class="regular-text" /></td>
mp-wp_genesis 181 </tr>
mp-wp_genesis 182
mp-wp_genesis 183 <tr>
mp-wp_genesis 184 <th><label for="last_name"><?php _e('Last name') ?></label></th>
mp-wp_genesis 185 <td><input type="text" name="last_name" id="last_name" value="<?php echo $profileuser->last_name ?>" class="regular-text" /></td>
mp-wp_genesis 186 </tr>
mp-wp_genesis 187
mp-wp_genesis 188 <tr>
mp-wp_genesis 189 <th><label for="nickname"><?php _e('Nickname') ?></label></th>
mp-wp_genesis 190 <td><input type="text" name="nickname" id="nickname" value="<?php echo $profileuser->nickname ?>" class="regular-text" /></td>
mp-wp_genesis 191 </tr>
mp-wp_genesis 192
mp-wp_genesis 193 <tr>
mp-wp_genesis 194 <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
mp-wp_genesis 195 <td>
mp-wp_genesis 196 <select name="display_name" id="display_name">
mp-wp_genesis 197 <?php
mp-wp_genesis 198 $public_display = array();
mp-wp_genesis 199 $public_display['display_displayname'] = $profileuser->display_name;
mp-wp_genesis 200 $public_display['display_nickname'] = $profileuser->nickname;
mp-wp_genesis 201 $public_display['display_username'] = $profileuser->user_login;
mp-wp_genesis 202 $public_display['display_firstname'] = $profileuser->first_name;
mp-wp_genesis 203 $public_display['display_firstlast'] = $profileuser->first_name.' '.$profileuser->last_name;
mp-wp_genesis 204 $public_display['display_lastfirst'] = $profileuser->last_name.' '.$profileuser->first_name;
mp-wp_genesis 205 $public_display = array_unique(array_filter(array_map('trim', $public_display)));
mp-wp_genesis 206 foreach($public_display as $id => $item) {
mp-wp_genesis 207 ?>
mp-wp_genesis 208 <option id="<?php echo $id; ?>" value="<?php echo $item; ?>"><?php echo $item; ?></option>
mp-wp_genesis 209 <?php
mp-wp_genesis 210 }
mp-wp_genesis 211 ?>
mp-wp_genesis 212 </select>
mp-wp_genesis 213 </td>
mp-wp_genesis 214 </tr>
mp-wp_genesis 215 </table>
mp-wp_genesis 216
mp-wp_genesis 217 <h3><?php _e('Contact Info') ?></h3>
mp-wp_genesis 218
mp-wp_genesis 219 <table class="form-table">
mp-wp_genesis 220 <tr>
mp-wp_genesis 221 <th><label for="email"><?php _e('E-mail') ?></label></th>
mp-wp_genesis 222 <td><input type="text" name="email" id="email" value="<?php echo $profileuser->user_email ?>" class="regular-text" /> <?php _e('Required.');?></td>
mp-wp_genesis 223 </tr>
mp-wp_genesis 224
mp-wp_genesis 225 <tr>
mp-wp_genesis 226 <th><label for="url"><?php _e('Website') ?></label></th>
mp-wp_genesis 227 <td><input type="text" name="url" id="url" value="<?php echo $profileuser->user_url ?>" class="regular-text" /></td>
mp-wp_genesis 228 </tr>
mp-wp_genesis 229
mp-wp_genesis 230 <tr>
mp-wp_genesis 231 <th><label for="aim"><?php _e('AIM') ?></label></th>
mp-wp_genesis 232 <td><input type="text" name="aim" id="aim" value="<?php echo $profileuser->aim ?>" class="regular-text" /></td>
mp-wp_genesis 233 </tr>
mp-wp_genesis 234
mp-wp_genesis 235 <tr>
mp-wp_genesis 236 <th><label for="yim"><?php _e('Yahoo IM') ?></label></th>
mp-wp_genesis 237 <td><input type="text" name="yim" id="yim" value="<?php echo $profileuser->yim ?>" class="regular-text" /></td>
mp-wp_genesis 238 </tr>
mp-wp_genesis 239
mp-wp_genesis 240 <tr>
mp-wp_genesis 241 <th><label for="jabber"><?php _e('Jabber / Google Talk') ?></label></th>
mp-wp_genesis 242 <td><input type="text" name="jabber" id="jabber" value="<?php echo $profileuser->jabber ?>" class="regular-text" /></td>
mp-wp_genesis 243 </tr>
mp-wp_genesis 244 </table>
mp-wp_genesis 245
mp-wp_genesis 246 <h3><?php $is_profile_page? _e('About Yourself') : _e('About the user'); ?></h3>
mp-wp_genesis 247
mp-wp_genesis 248 <table class="form-table">
mp-wp_genesis 249 <tr>
mp-wp_genesis 250 <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
mp-wp_genesis 251 <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea><br /><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></td>
mp-wp_genesis 252 </tr>
mp-wp_genesis 253
mp-wp_genesis 254 <?php
mp-wp_genesis 255 $show_password_fields = apply_filters('show_password_fields', true);
mp-wp_genesis 256 if ( $show_password_fields ) :
mp-wp_genesis 257 ?>
mp-wp_genesis 258 <tr>
mp-wp_genesis 259 <th><label for="pass1"><?php _e('New Password'); ?></label></th>
mp-wp_genesis 260 <td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <?php _e("If you would like to change the password type a new one. Otherwise leave this blank."); ?><br />
mp-wp_genesis 261 <input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <?php _e("Type your new password again."); ?><br />
mp-wp_genesis 262 <?php if ( $is_profile_page ): ?>
mp-wp_genesis 263 <div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
mp-wp_genesis 264 <p><?php _e('Hint: Your password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).'); ?></p>
mp-wp_genesis 265 <?php endif; ?>
mp-wp_genesis 266 </td>
mp-wp_genesis 267 </tr>
mp-wp_genesis 268 <?php endif; ?>
mp-wp_genesis 269 </table>
mp-wp_genesis 270
mp-wp_genesis 271 <?php
mp-wp_genesis 272 if ( $is_profile_page ) {
mp-wp_genesis 273 do_action('show_user_profile');
mp-wp_genesis 274 } else {
mp-wp_genesis 275 do_action('edit_user_profile');
mp-wp_genesis 276 }
mp-wp_genesis 277 ?>
mp-wp_genesis 278
mp-wp_genesis 279 <?php if (count($profileuser->caps) > count($profileuser->roles)): ?>
mp-wp_genesis 280 <br class="clear" />
mp-wp_genesis 281 <table width="99%" style="border: none;" cellspacing="2" cellpadding="3" class="editform">
mp-wp_genesis 282 <tr>
mp-wp_genesis 283 <th scope="row"><?php _e('Additional Capabilities') ?></th>
mp-wp_genesis 284 <td><?php
mp-wp_genesis 285 $output = '';
mp-wp_genesis 286 foreach($profileuser->caps as $cap => $value) {
mp-wp_genesis 287 if(!$wp_roles->is_role($cap)) {
mp-wp_genesis 288 if($output != '') $output .= ', ';
mp-wp_genesis 289 $output .= $value ? $cap : "Denied: {$cap}";
mp-wp_genesis 290 }
mp-wp_genesis 291 }
mp-wp_genesis 292 echo $output;
mp-wp_genesis 293 ?></td>
mp-wp_genesis 294 </tr>
mp-wp_genesis 295 </table>
mp-wp_genesis 296 <?php endif; ?>
mp-wp_genesis 297
mp-wp_genesis 298 <p class="submit">
mp-wp_genesis 299 <input type="hidden" name="action" value="update" />
mp-wp_genesis 300 <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />
mp-wp_genesis 301 <input type="submit" class="button-primary" value="<?php $is_profile_page? _e('Update Profile') : _e('Update User') ?>" name="submit" />
mp-wp_genesis 302 </p>
mp-wp_genesis 303 </form>
mp-wp_genesis 304 </div>
mp-wp_genesis 305 <?php
mp-wp_genesis 306 break;
mp-wp_genesis 307 }
mp-wp_genesis 308
mp-wp_genesis 309 include('admin-footer.php');
mp-wp_genesis 310 ?>