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 );
46 $('#pass1').keyup( check_pass_strength )
47 $('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
50 jQuery(document).ready( function() {
51 jQuery('#pass1,#pass2').attr('autocomplete','off');
57 if ( $is_profile_page ) {
58 add_action('admin_head', 'profile_js');
59 wp_enqueue_script('jquery');
60 wp_enqueue_script('password-strength-meter');
63 $title = $is_profile_page? __('Profile') : __('Edit User');
64 if ( current_user_can('edit_users') && !$is_profile_page )
65 $submenu_file = 'users.php';
67 $submenu_file = 'profile.php';
68 $parent_file = 'users.php';
70 wp_reset_vars(array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer'));
72 $wp_http_referer = remove_query_arg(array('update', 'delete_count'), stripslashes($wp_http_referer));
74 $user_id = (int) $user_id;
77 if ( $is_profile_page ) {
78 $current_user = wp_get_current_user();
79 $user_id = $current_user->ID;
81 wp_die(__('Invalid user ID.'));
87 check_admin_referer();
89 /* TODO: Switch all posts from one user to another user */
95 check_admin_referer('update-user_' . $user_id);
97 if ( !current_user_can('edit_user', $user_id) )
98 wp_die(__('You do not have permission to edit this user.'));
100 if ( $is_profile_page ) {
101 do_action('personal_options_update');
104 $errors = edit_user($user_id);
106 if( !is_wp_error( $errors ) ) {
107 $redirect = ($is_profile_page? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
108 $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
109 wp_redirect($redirect);
114 $profileuser = get_user_to_edit($user_id);
116 if ( !current_user_can('edit_user', $user_id) )
117 wp_die(__('You do not have permission to edit this user.'));
119 include ('admin-header.php');
122 <?php if ( isset($_GET['updated']) ) : ?>
123 <div id="message" class="updated fade">
124 <p><strong><?php _e('User updated.') ?></strong></p>
125 <?php if ( $wp_http_referer && !$is_profile_page ) : ?>
126 <p><a href="users.php"><?php _e('« Back to Authors and Users'); ?></a></p>
130 <?php if ( is_wp_error( $errors ) ) : ?>
134 foreach( $errors->get_error_messages() as $message )
135 echo "<li>$message</li>";
141 <div class="wrap" id="profile-page">
142 <h2><?php $is_profile_page? _e('Your Profile and Personal Options') : _e('Edit User'); ?></h2>
144 <form name="profile" id="your-profile" action="" method="post">
145 <?php wp_nonce_field('update-user_' . $user_id) ?>
146 <?php if ( $wp_http_referer ) : ?>
147 <input type="hidden" name="wp_http_referer" value="<?php echo clean_url($wp_http_referer); ?>" />
150 <input type="hidden" name="from" value="profile" />
151 <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
154 <h3><?php _e('Personal Options'); ?></h3>
156 <table class="form-table">
157 <?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?>
159 <th scope="row"><?php _e('Visual Editor')?></th>
160 <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>
164 <th scope="row"><?php _e('Admin Color Scheme')?></th>
167 $current_color = get_user_option('admin_color');
168 if ( empty($current_color) )
169 $current_color = 'fresh';
170 foreach ( $_wp_admin_css_colors as $color => $color_info ): ?>
171 <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); ?> />
172 <table class="color-palette">
175 foreach ( $color_info->colors as $html_color ): ?>
176 <td style="background-color: <?php echo $html_color ?>" title="<?php echo $color ?>"> </td>
181 <label for="admin_color_<?php echo $color; ?>"><?php echo $color_info->name ?></label>
189 if ( $is_profile_page ) {
190 do_action('profile_personal_options');
194 <h3><?php _e('Name') ?></h3>
196 <table class="form-table">
198 <th><label for="user_login"><?php _e('Username'); ?></label></th>
199 <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>
202 <?php if ( !$is_profile_page ): ?>
203 <tr><th><label for="role"><?php _e('Role:') ?></label></th>
205 // print_r($profileuser);
206 echo '<td><select name="role" id="role">';
208 $user_has_role = false;
209 foreach($wp_roles->role_names as $role => $name) {
210 $name = translate_with_context($name);
211 if ( $profileuser->has_cap($role) ) {
212 $selected = ' selected="selected"';
213 $user_has_role = true;
217 $role_list .= "<option value=\"{$role}\"{$selected}>{$name}</option>";
219 if ( $user_has_role )
220 $role_list .= '<option value="">' . __('— No role for this blog —') . '</option>';
222 $role_list .= '<option value="" selected="selected">' . __('— No role for this blog —') . '</option>';
223 echo $role_list . '</select></td></tr>';
228 <th><label for="first_name"><?php _e('First name') ?></label></th>
229 <td><input type="text" name="first_name" id="first_name" value="<?php echo $profileuser->first_name ?>" /></td>
233 <th><label for="last_name"><?php _e('Last name') ?></label></th>
234 <td><input type="text" name="last_name" id="last_name" value="<?php echo $profileuser->last_name ?>" /></td>
238 <th><label for="nickname"><?php _e('Nickname') ?></label></th>
239 <td><input type="text" name="nickname" id="nickname" value="<?php echo $profileuser->nickname ?>" /></td>
243 <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
245 <select name="display_name" id="display_name">
247 $public_display = array();
248 $public_display[] = $profileuser->display_name;
249 $public_display[] = $profileuser->nickname;
250 $public_display[] = $profileuser->user_login;
251 $public_display[] = $profileuser->first_name;
252 $public_display[] = $profileuser->first_name.' '.$profileuser->last_name;
253 $public_display[] = $profileuser->last_name.' '.$profileuser->first_name;
254 $public_display = array_unique(array_filter(array_map('trim', $public_display)));
255 foreach($public_display as $item) {
257 <option value="<?php echo $item; ?>"><?php echo $item; ?></option>
266 <h3><?php _e('Contact Info') ?></h3>
268 <table class="form-table">
270 <th><label for="email"><?php _e('E-mail') ?></label></th>
271 <td><input type="text" name="email" id="email" value="<?php echo $profileuser->user_email ?>" /> <?php _e('Required'); ?></td>
275 <th><label for="url"><?php _e('Website') ?></label></th>
276 <td><input type="text" name="url" id="url" value="<?php echo $profileuser->user_url ?>" /></td>
280 <th><label for="aim"><?php _e('AIM') ?></label></th>
281 <td><input type="text" name="aim" id="aim" value="<?php echo $profileuser->aim ?>" /></td>
285 <th><label for="yim"><?php _e('Yahoo IM') ?></label></th>
286 <td><input type="text" name="yim" id="yim" value="<?php echo $profileuser->yim ?>" /></td>
290 <th><label for="jabber"><?php _e('Jabber / Google Talk') ?></label></th>
291 <td><input type="text" name="jabber" id="jabber" value="<?php echo $profileuser->jabber ?>" /></td>
295 <h3><?php $is_profile_page? _e('About Yourself') : _e('About the user'); ?></h3>
297 <table class="form-table">
299 <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
300 <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>
304 $show_password_fields = apply_filters('show_password_fields', true);
305 if ( $show_password_fields ) :
308 <th><label for="pass1"><?php _e('New Password:'); ?></label></th>
309 <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 />
310 <input type="password" name="pass2" id="pass2" size="16" value="" /> <?php _e("Type your new password again."); ?><br />
311 <?php if ( $is_profile_page ): ?>
312 <p><strong><?php _e('Password Strength:'); ?></strong></p>
313 <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.'); ?>
321 if ( $is_profile_page ) {
322 do_action('show_user_profile');
324 do_action('edit_user_profile');
328 <?php if (count($profileuser->caps) > count($profileuser->roles)): ?>
330 <table width="99%" style="border: none;" cellspacing="2" cellpadding="3" class="editform">
332 <th scope="row"><?php _e('Additional Capabilities:') ?></th>
335 foreach($profileuser->caps as $cap => $value) {
336 if(!$wp_roles->is_role($cap)) {
337 if($output != '') $output .= ', ';
338 $output .= $value ? $cap : "Denied: {$cap}";
348 <input type="hidden" name="action" value="update" />
349 <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />
350 <input type="submit" value="<?php $is_profile_page? _e('Update Profile') : _e('Update User') ?>" name="submit" />
358 include('admin-footer.php');