3 require_once('admin.php');
5 if ( defined('IS_PROFILE_PAGE') && IS_PROFILE_PAGE )
6 $is_profile_page = true;
8 $is_profile_page = false;
10 function profile_js ( ) {
12 <script type="text/javascript">
13 function check_pass_strength ( ) {
15 var pass = jQuery('#pass1').val();
16 var user = jQuery('#user_login').val();
18 // get the result as an object, i'm tired of typing it
19 var res = jQuery('#pass-strength-result');
21 var strength = passwordStrength(pass, user);
23 jQuery(res).removeClass('short bad good strong');
25 if ( strength == pwsL10n.bad ) {
26 jQuery(res).addClass('bad');
27 jQuery(res).html( pwsL10n.bad );
29 else if ( strength == pwsL10n.good ) {
30 jQuery(res).addClass('good');
31 jQuery(res).html( pwsL10n.good );
33 else if ( strength == pwsL10n.strong ) {
34 jQuery(res).addClass('strong');
35 jQuery(res).html( pwsL10n.strong );
38 // this catches 'Too short' and the off chance anything else comes along
39 jQuery(res).addClass('short');
40 jQuery(res).html( pwsL10n.short );
45 function update_nickname ( ) {
47 var nickname = jQuery('#nickname').val();
48 var display_nickname = jQuery('#display_nickname').val();
50 if ( nickname == '' ) {
51 jQuery('#display_nickname').remove();
53 jQuery('#display_nickname').val(nickname).html(nickname);
58 $('#pass1').keyup( check_pass_strength )
59 $('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
62 jQuery(document).ready( function() {
63 jQuery('#pass1,#pass2').attr('autocomplete','off');
64 jQuery('#nickname').blur(update_nickname);
70 if ( $is_profile_page ) {
71 add_action('admin_head', 'profile_js');
72 wp_enqueue_script('jquery');
73 wp_enqueue_script('password-strength-meter');
76 $title = $is_profile_page? __('Profile') : __('Edit User');
77 if ( current_user_can('edit_users') && !$is_profile_page )
78 $submenu_file = 'users.php';
80 $submenu_file = 'profile.php';
81 $parent_file = 'users.php';
83 wp_reset_vars(array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer'));
85 $wp_http_referer = remove_query_arg(array('update', 'delete_count'), stripslashes($wp_http_referer));
87 $user_id = (int) $user_id;
90 if ( $is_profile_page ) {
91 $current_user = wp_get_current_user();
92 $user_id = $current_user->ID;
94 wp_die(__('Invalid user ID.'));
100 check_admin_referer();
102 /* TODO: Switch all posts from one user to another user */
108 check_admin_referer('update-user_' . $user_id);
110 if ( !current_user_can('edit_user', $user_id) )
111 wp_die(__('You do not have permission to edit this user.'));
113 if ( $is_profile_page ) {
114 do_action('personal_options_update');
117 $errors = edit_user($user_id);
119 if( !is_wp_error( $errors ) ) {
120 $redirect = ($is_profile_page? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
121 $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
122 wp_redirect($redirect);
127 $profileuser = get_user_to_edit($user_id);
129 if ( !current_user_can('edit_user', $user_id) )
130 wp_die(__('You do not have permission to edit this user.'));
132 include ('admin-header.php');
135 <?php if ( isset($_GET['updated']) ) : ?>
136 <div id="message" class="updated fade">
137 <p><strong><?php _e('User updated.') ?></strong></p>
138 <?php if ( $wp_http_referer && !$is_profile_page ) : ?>
139 <p><a href="users.php"><?php _e('« Back to Authors and Users'); ?></a></p>
143 <?php if ( is_wp_error( $errors ) ) : ?>
147 foreach( $errors->get_error_messages() as $message )
148 echo "<li>$message</li>";
154 <div class="wrap" id="profile-page">
155 <h2><?php $is_profile_page? _e('Your Profile and Personal Options') : _e('Edit User'); ?></h2>
157 <form name="profile" id="your-profile" action="" method="post">
158 <?php wp_nonce_field('update-user_' . $user_id) ?>
159 <?php if ( $wp_http_referer ) : ?>
160 <input type="hidden" name="wp_http_referer" value="<?php echo clean_url($wp_http_referer); ?>" />
163 <input type="hidden" name="from" value="profile" />
164 <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
167 <h3><?php _e('Personal Options'); ?></h3>
169 <table class="form-table">
170 <?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?>
172 <th scope="row"><?php _e('Visual Editor')?></th>
173 <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', $profileuser->rich_editing); ?> /> <?php _e('Use the visual editor when writing'); ?></label></td>
177 <th scope="row"><?php _e('Admin Color Scheme')?></th>
178 <td><fieldset><legend class="hidden"><?php _e('Admin Color Scheme')?></legend>
180 $current_color = get_user_option('admin_color', $user_id);
181 if ( empty($current_color) )
182 $current_color = 'fresh';
183 foreach ( $_wp_admin_css_colors as $color => $color_info ): ?>
184 <div class="color-option"><input name="admin_color" id="admin_color_<?php echo $color; ?>" type="radio" value="<?php echo $color ?>" class="tog" <?php checked($color, $current_color); ?> />
185 <table class="color-palette">
188 foreach ( $color_info->colors as $html_color ): ?>
189 <td style="background-color: <?php echo $html_color ?>" title="<?php echo $color ?>"> </td>
194 <label for="admin_color_<?php echo $color; ?>"><?php echo $color_info->name ?></label>
202 if ( $is_profile_page ) {
203 do_action('profile_personal_options');
207 <h3><?php _e('Name') ?></h3>
209 <table class="form-table">
211 <th><label for="user_login"><?php _e('Username'); ?></label></th>
212 <td><input type="text" name="user_login" id="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" /> <?php _e('Your username cannot be changed'); ?></td>
215 <?php if ( !$is_profile_page ): ?>
216 <tr><th><label for="role"><?php _e('Role:') ?></label></th>
218 // print_r($profileuser);
219 echo '<td><select name="role" id="role">';
221 $user_has_role = false;
222 foreach($wp_roles->role_names as $role => $name) {
223 $name = translate_with_context($name);
224 if ( $profileuser->has_cap($role) ) {
225 $selected = ' selected="selected"';
226 $user_has_role = true;
230 $role_list .= "<option value=\"{$role}\"{$selected}>{$name}</option>";
232 if ( $user_has_role )
233 $role_list .= '<option value="">' . __('— No role for this blog —') . '</option>';
235 $role_list .= '<option value="" selected="selected">' . __('— No role for this blog —') . '</option>';
236 echo $role_list . '</select></td></tr>';
241 <th><label for="first_name"><?php _e('First name') ?></label></th>
242 <td><input type="text" name="first_name" id="first_name" value="<?php echo $profileuser->first_name ?>" /></td>
246 <th><label for="last_name"><?php _e('Last name') ?></label></th>
247 <td><input type="text" name="last_name" id="last_name" value="<?php echo $profileuser->last_name ?>" /></td>
251 <th><label for="nickname"><?php _e('Nickname') ?></label></th>
252 <td><input type="text" name="nickname" id="nickname" value="<?php echo $profileuser->nickname ?>" /></td>
256 <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
258 <select name="display_name" id="display_name">
260 $public_display = array();
261 $public_display['display_displayname'] = $profileuser->display_name;
262 $public_display['display_nickname'] = $profileuser->nickname;
263 $public_display['display_username'] = $profileuser->user_login;
264 $public_display['display_firstname'] = $profileuser->first_name;
265 $public_display['display_firstlast'] = $profileuser->first_name.' '.$profileuser->last_name;
266 $public_display['display_lastfirst'] = $profileuser->last_name.' '.$profileuser->first_name;
267 $public_display = array_unique(array_filter(array_map('trim', $public_display)));
268 foreach($public_display as $id => $item) {
270 <option id="<?php echo $id; ?>" value="<?php echo $item; ?>"><?php echo $item; ?></option>
279 <h3><?php _e('Contact Info') ?></h3>
281 <table class="form-table">
283 <th><label for="email"><?php _e('E-mail') ?></label></th>
284 <td><input type="text" name="email" id="email" value="<?php echo $profileuser->user_email ?>" /> <?php _e('Required'); ?></td>
288 <th><label for="url"><?php _e('Website') ?></label></th>
289 <td><input type="text" name="url" id="url" value="<?php echo $profileuser->user_url ?>" /></td>
293 <th><label for="aim"><?php _e('AIM') ?></label></th>
294 <td><input type="text" name="aim" id="aim" value="<?php echo $profileuser->aim ?>" /></td>
298 <th><label for="yim"><?php _e('Yahoo IM') ?></label></th>
299 <td><input type="text" name="yim" id="yim" value="<?php echo $profileuser->yim ?>" /></td>
303 <th><label for="jabber"><?php _e('Jabber / Google Talk') ?></label></th>
304 <td><input type="text" name="jabber" id="jabber" value="<?php echo $profileuser->jabber ?>" /></td>
308 <h3><?php $is_profile_page? _e('About Yourself') : _e('About the user'); ?></h3>
310 <table class="form-table">
312 <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
313 <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>
317 $show_password_fields = apply_filters('show_password_fields', true);
318 if ( $show_password_fields ) :
321 <th><label for="pass1"><?php _e('New Password'); ?></label></th>
322 <td><input type="password" name="pass1" id="pass1" size="16" value="" /> <?php _e("If you would like to change the password type a new one. Otherwise leave this blank."); ?><br />
323 <input type="password" name="pass2" id="pass2" size="16" value="" /> <?php _e("Type your new password again."); ?><br />
324 <?php if ( $is_profile_page ): ?>
325 <p><strong><?php _e('Password Strength'); ?></strong></p>
326 <div id="pass-strength-result"><?php _e('Too short'); ?></div> <?php _e('Hint: Use upper and lower case characters, numbers and symbols like !"?$%^&( in your password.'); ?>
334 if ( $is_profile_page ) {
335 do_action('show_user_profile');
337 do_action('edit_user_profile');
341 <?php if (count($profileuser->caps) > count($profileuser->roles)): ?>
343 <table width="99%" style="border: none;" cellspacing="2" cellpadding="3" class="editform">
345 <th scope="row"><?php _e('Additional Capabilities') ?></th>
348 foreach($profileuser->caps as $cap => $value) {
349 if(!$wp_roles->is_role($cap)) {
350 if($output != '') $output .= ', ';
351 $output .= $value ? $cap : "Denied: {$cap}";
361 <input type="hidden" name="action" value="update" />
362 <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />
363 <input type="submit" value="<?php $is_profile_page? _e('Update Profile') : _e('Update User') ?>" name="submit" />
371 include('admin-footer.php');