]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/user-edit.php
WordPress 4.1-scripts
[autoinstalls/wordpress.git] / wp-admin / user-edit.php
1 <?php
2 /**
3  * Edit user administration panel.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8
9 /** WordPress Administration Bootstrap */
10 require_once( dirname( __FILE__ ) . '/admin.php' );
11
12 wp_reset_vars( array( 'action', 'user_id', 'wp_http_referer' ) );
13
14 $user_id = (int) $user_id;
15 $current_user = wp_get_current_user();
16 if ( ! defined( 'IS_PROFILE_PAGE' ) )
17         define( 'IS_PROFILE_PAGE', ( $user_id == $current_user->ID ) );
18
19 if ( ! $user_id && IS_PROFILE_PAGE )
20         $user_id = $current_user->ID;
21 elseif ( ! $user_id && ! IS_PROFILE_PAGE )
22         wp_die(__( 'Invalid user ID.' ) );
23 elseif ( ! get_userdata( $user_id ) )
24         wp_die( __('Invalid user ID.') );
25
26 wp_enqueue_script('user-profile');
27
28 $title = IS_PROFILE_PAGE ? __('Profile') : __('Edit User');
29 if ( current_user_can('edit_users') && !IS_PROFILE_PAGE )
30         $submenu_file = 'users.php';
31 else
32         $submenu_file = 'profile.php';
33
34 if ( current_user_can('edit_users') && !is_user_admin() )
35         $parent_file = 'users.php';
36 else
37         $parent_file = 'profile.php';
38
39 $profile_help = '<p>' . __('Your profile contains information about you (your &#8220;account&#8221;) as well as some personal options related to using WordPress.') . '</p>' .
40         '<p>' . __('You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.') . '</p>' .
41         '<p>' . __('Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts.') . '</p>' .
42         '<p>' . __( 'You can log out of other devices, such as your phone or a public computer, by clicking the Log Out of All Other Sessions button. The button will only display if you are logged in to more than one device.' ) . '</p>' .
43         '<p>' . __('Required fields are indicated; the rest are optional. Profile information will only be displayed if your theme is set up to do so.') . '</p>' .
44         '<p>' . __('Remember to click the Update Profile button when you are finished.') . '</p>';
45
46 get_current_screen()->add_help_tab( array(
47         'id'      => 'overview',
48         'title'   => __('Overview'),
49         'content' => $profile_help,
50 ) );
51
52 get_current_screen()->set_help_sidebar(
53     '<p><strong>' . __('For more information:') . '</strong></p>' .
54     '<p>' . __('<a href="http://codex.wordpress.org/Users_Your_Profile_Screen" target="_blank">Documentation on User Profiles</a>') . '</p>' .
55     '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
56 );
57
58 $wp_http_referer = remove_query_arg(array('update', 'delete_count'), $wp_http_referer );
59
60 $user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' );
61
62 /**
63  * Optional SSL preference that can be turned on by hooking to the 'personal_options' action.
64  *
65  * @since 2.7.0
66  *
67  * @param object $user User data object
68  */
69 function use_ssl_preference($user) {
70 ?>
71         <tr class="user-use-ssl-wrap">
72                 <th scope="row"><?php _e('Use https')?></th>
73                 <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>
74         </tr>
75 <?php
76 }
77
78 /**
79  * Filter whether to allow administrators on Multisite to edit every user.
80  *
81  * Enabling the user editing form via this filter also hinges on the user holding
82  * the 'manage_network_users' cap, and the logged-in user not matching the user
83  * profile open for editing.
84  *
85  * The filter was introduced to replace the EDIT_ANY_USER constant.
86  *
87  * @since 3.0.0
88  *
89  * @param bool $allow Whether to allow editing of any user. Default true.
90  */
91 if ( is_multisite()
92         && ! current_user_can( 'manage_network_users' )
93         && $user_id != $current_user->ID
94         && ! apply_filters( 'enable_edit_any_user_configuration', true )
95 ) {
96         wp_die( __( 'You do not have permission to edit this user.' ) );
97 }
98
99 // Execute confirmed email change. See send_confirmation_on_profile_email().
100 if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
101         $new_email = get_option( $current_user->ID . '_new_email' );
102         if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) {
103                 $user = new stdClass;
104                 $user->ID = $current_user->ID;
105                 $user->user_email = esc_html( trim( $new_email[ 'newemail' ] ) );
106                 if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) )
107                         $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
108                 wp_update_user( $user );
109                 delete_option( $current_user->ID . '_new_email' );
110                 wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
111                 die();
112         }
113 } elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' == $_GET['dismiss'] ) {
114         delete_option( $current_user->ID . '_new_email' );
115         wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
116         die();
117 }
118
119 switch ($action) {
120 case 'update':
121
122 check_admin_referer('update-user_' . $user_id);
123
124 if ( !current_user_can('edit_user', $user_id) )
125         wp_die(__('You do not have permission to edit this user.'));
126
127 if ( IS_PROFILE_PAGE ) {
128         /**
129          * Fires before the page loads on the 'Your Profile' editing screen.
130          *
131          * The action only fires if the current user is editing their own profile.
132          *
133          * @since 2.0.0
134          *
135          * @param int $user_id The user ID.
136          */
137         do_action( 'personal_options_update', $user_id );
138 } else {
139         /**
140          * Fires before the page loads on the 'Edit User' screen.
141          *
142          * @since 2.7.0
143          *
144          * @param int $user_id The user ID.
145          */
146         do_action( 'edit_user_profile_update', $user_id );
147 }
148
149 if ( !is_multisite() ) {
150         $errors = edit_user($user_id);
151 } else {
152         $user = get_userdata( $user_id );
153
154         // Update the email address in signups, if present.
155         if ( $user->user_login && isset( $_POST[ 'email' ] ) && is_email( $_POST[ 'email' ] ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) )
156                 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST[ 'email' ], $user_login ) );
157
158         // We must delete the user from the current blog if WP added them after editing.
159         $delete_role = false;
160         $blog_prefix = $wpdb->get_blog_prefix();
161         if ( $user_id != $current_user->ID ) {
162                 $cap = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = '{$user_id}' AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'" );
163                 if ( !is_network_admin() && null == $cap && $_POST[ 'role' ] == '' ) {
164                         $_POST[ 'role' ] = 'contributor';
165                         $delete_role = true;
166                 }
167         }
168         if ( !isset( $errors ) || ( isset( $errors ) && is_object( $errors ) && false == $errors->get_error_codes() ) )
169                 $errors = edit_user($user_id);
170         if ( $delete_role ) // stops users being added to current blog when they are edited
171                 delete_user_meta( $user_id, $blog_prefix . 'capabilities' );
172
173         if ( is_multisite() && is_network_admin() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) )
174                 empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
175 }
176
177 if ( !is_wp_error( $errors ) ) {
178         $redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) );
179         if ( $wp_http_referer )
180                 $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
181         wp_redirect($redirect);
182         exit;
183 }
184
185 default:
186 $profileuser = get_user_to_edit($user_id);
187
188 if ( !current_user_can('edit_user', $user_id) )
189         wp_die(__('You do not have permission to edit this user.'));
190
191 $sessions = WP_Session_Tokens::get_instance( $profileuser->ID );
192
193 include(ABSPATH . 'wp-admin/admin-header.php');
194 ?>
195
196 <?php if ( !IS_PROFILE_PAGE && is_super_admin( $profileuser->ID ) && current_user_can( 'manage_network_options' ) ) { ?>
197         <div class="updated"><p><strong><?php _e('Important:'); ?></strong> <?php _e('This user has super admin privileges.'); ?></p></div>
198 <?php } ?>
199 <?php if ( isset($_GET['updated']) ) : ?>
200 <div id="message" class="updated">
201         <?php if ( IS_PROFILE_PAGE ) : ?>
202         <p><strong><?php _e('Profile updated.') ?></strong></p>
203         <?php else: ?>
204         <p><strong><?php _e('User updated.') ?></strong></p>
205         <?php endif; ?>
206         <?php if ( $wp_http_referer && !IS_PROFILE_PAGE ) : ?>
207         <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e('&larr; Back to Users'); ?></a></p>
208         <?php endif; ?>
209 </div>
210 <?php endif; ?>
211 <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
212 <div class="error"><p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p></div>
213 <?php endif; ?>
214
215 <div class="wrap" id="profile-page">
216 <h2>
217 <?php
218 echo esc_html( $title );
219 if ( ! IS_PROFILE_PAGE ) {
220         if ( current_user_can( 'create_users' ) ) { ?>
221                 <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
222         <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
223                 <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
224         <?php }
225 } ?>
226 </h2>
227 <form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post" novalidate="novalidate"<?php
228         /**
229          * Fires inside the your-profile form tag on the user editing screen.
230          *
231          * @since 3.0.0
232          */
233         do_action( 'user_edit_form_tag' );
234 ?>>
235 <?php wp_nonce_field('update-user_' . $user_id) ?>
236 <?php if ( $wp_http_referer ) : ?>
237         <input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" />
238 <?php endif; ?>
239 <p>
240 <input type="hidden" name="from" value="profile" />
241 <input type="hidden" name="checkuser_id" value="<?php echo get_current_user_id(); ?>" />
242 </p>
243
244 <h3><?php _e('Personal Options'); ?></h3>
245
246 <table class="form-table">
247 <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?>
248         <tr class="user-rich-editing-wrap">
249                 <th scope="row"><label for="rich_editing"><?php _e( 'Visual Editor' )?></label></th>
250                 <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php if ( ! empty( $profileuser->rich_editing ) ) checked( 'false', $profileuser->rich_editing ); ?> /> <?php _e( 'Disable the visual editor when writing' ); ?></label></td>
251         </tr>
252 <?php endif; ?>
253 <?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
254 <tr class="user-admin-color-wrap">
255 <th scope="row"><?php _e('Admin Color Scheme')?></th>
256 <td><?php
257         /**
258          * Fires in the 'Admin Color Scheme' section of the user editing screen.
259          *
260          * The section is only enabled if a callback is hooked to the action,
261          * and if there is more than one defined color scheme for the admin.
262          *
263          * @since 3.0.0
264          * @since 3.8.1 Added `$user_id` parameter.
265          *
266          * @param int $user_id The user ID.
267          */
268         do_action( 'admin_color_scheme_picker', $user_id );
269 ?></td>
270 </tr>
271 <?php
272 endif; // $_wp_admin_css_colors
273 if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?>
274 <tr class="user-comment-shortcuts-wrap">
275 <th scope="row"><label for="comment_shortcuts"><?php _e( 'Keyboard Shortcuts' ); ?></label></th>
276 <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.'); ?></label> <?php _e('<a href="http://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td>
277 </tr>
278 <?php endif; ?>
279 <tr class="show-admin-bar user-admin-bar-front-wrap">
280 <th scope="row"><label for="admin_bar_front"><?php _e( 'Toolbar' )?></label></th>
281 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Toolbar') ?></span></legend>
282 <label for="admin_bar_front">
283 <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
284 <?php _e( 'Show Toolbar when viewing site' ); ?></label><br />
285 </fieldset>
286 </td>
287 </tr>
288 <?php
289 /**
290  * Fires at the end of the 'Personal Options' settings table on the user editing screen.
291  *
292  * @since 2.7.0
293  *
294  * @param WP_User $profileuser The current WP_User object.
295  */
296 do_action( 'personal_options', $profileuser );
297 ?>
298
299 </table>
300 <?php
301         if ( IS_PROFILE_PAGE ) {
302                 /**
303                  * Fires after the 'Personal Options' settings table on the 'Your Profile' editing screen.
304                  *
305                  * The action only fires if the current user is editing their own profile.
306                  *
307                  * @since 2.0.0
308                  *
309                  * @param WP_User $profileuser The current WP_User object.
310                  */
311                 do_action( 'profile_personal_options', $profileuser );
312         }
313 ?>
314
315 <h3><?php _e('Name') ?></h3>
316
317 <table class="form-table">
318         <tr class="user-user-login-wrap">
319                 <th><label for="user_login"><?php _e('Username'); ?></label></th>
320                 <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr($profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e('Usernames cannot be changed.'); ?></span></td>
321         </tr>
322
323 <?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?>
324 <tr class="user-role-wrap"><th><label for="role"><?php _e('Role') ?></label></th>
325 <td><select name="role" id="role">
326 <?php
327 // Compare user role against currently editable roles
328 $user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) );
329 $user_role  = array_shift( $user_roles );
330
331 // print the full list of roles with the primary one selected.
332 wp_dropdown_roles($user_role);
333
334 // print the 'no role' option. Make it selected if the user has no role yet.
335 if ( $user_role )
336         echo '<option value="">' . __('&mdash; No role for this site &mdash;') . '</option>';
337 else
338         echo '<option value="" selected="selected">' . __('&mdash; No role for this site &mdash;') . '</option>';
339 ?>
340 </select></td></tr>
341 <?php endif; //!IS_PROFILE_PAGE
342
343 if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?>
344 <tr class="user-super-admin-wrap"><th><?php _e('Super Admin'); ?></th>
345 <td>
346 <?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) || ! is_super_admin( $profileuser->ID ) ) : ?>
347 <p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p>
348 <?php else : ?>
349 <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
350 <?php endif; ?>
351 </td></tr>
352 <?php } ?>
353
354 <tr class="user-first-name-wrap">
355         <th><label for="first_name"><?php _e('First Name') ?></label></th>
356         <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr($profileuser->first_name) ?>" class="regular-text" /></td>
357 </tr>
358
359 <tr class="user-last-name-wrap">
360         <th><label for="last_name"><?php _e('Last Name') ?></label></th>
361         <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr($profileuser->last_name) ?>" class="regular-text" /></td>
362 </tr>
363
364 <tr class="user-nickname-wrap">
365         <th><label for="nickname"><?php _e('Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
366         <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></td>
367 </tr>
368
369 <tr class="user-display-name-wrap">
370         <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
371         <td>
372                 <select name="display_name" id="display_name">
373                 <?php
374                         $public_display = array();
375                         $public_display['display_nickname']  = $profileuser->nickname;
376                         $public_display['display_username']  = $profileuser->user_login;
377
378                         if ( !empty($profileuser->first_name) )
379                                 $public_display['display_firstname'] = $profileuser->first_name;
380
381                         if ( !empty($profileuser->last_name) )
382                                 $public_display['display_lastname'] = $profileuser->last_name;
383
384                         if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
385                                 $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
386                                 $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
387                         }
388
389                         if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere
390                                 $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
391
392                         $public_display = array_map( 'trim', $public_display );
393                         $public_display = array_unique( $public_display );
394
395                         foreach ( $public_display as $id => $item ) {
396                 ?>
397                         <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>
398                 <?php
399                         }
400                 ?>
401                 </select>
402         </td>
403 </tr>
404 </table>
405
406 <h3><?php _e('Contact Info') ?></h3>
407
408 <table class="form-table">
409 <tr class="user-email-wrap">
410         <th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
411         <td><input type="email" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ) ?>" class="regular-text ltr" />
412         <?php
413         $new_email = get_option( $current_user->ID . '_new_email' );
414         if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : ?>
415         <div class="updated inline">
416         <p><?php printf( __('There is a pending change of your e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), $new_email['newemail'], esc_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ) ) ); ?></p>
417         </div>
418         <?php endif; ?>
419         </td>
420 </tr>
421
422 <tr class="user-url-wrap">
423         <th><label for="url"><?php _e('Website') ?></label></th>
424         <td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ) ?>" class="regular-text code" /></td>
425 </tr>
426
427 <?php
428         foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) {
429 ?>
430 <tr class="user-<?php echo $name; ?>-wrap">
431         <th><label for="<?php echo $name; ?>">
432                 <?php
433                 /**
434                  * Filter a user contactmethod label.
435                  *
436                  * The dynamic portion of the filter hook, `$name`, refers to
437                  * each of the keys in the contactmethods array.
438                  *
439                  * @since 2.9.0
440                  *
441                  * @param string $desc The translatable label for the contactmethod.
442                  */
443                 echo apply_filters( "user_{$name}_label", $desc );
444                 ?>
445         </label></th>
446         <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>
447 </tr>
448 <?php
449         }
450 ?>
451 </table>
452
453 <h3><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3>
454
455 <table class="form-table">
456 <tr class="user-description-wrap">
457         <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
458         <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea>
459         <p class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p></td>
460 </tr>
461
462 <?php
463 /** This filter is documented in wp-admin/user-new.php */
464 $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser );
465 if ( $show_password_fields ) :
466 ?>
467 <tr id="password" class="user-pass1-wrap">
468         <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
469         <td>
470                 <input class="hidden" value=" " /><!-- #24364 workaround -->
471                 <input type="password" name="pass1" id="pass1" class="regular-text" size="16" value="" autocomplete="off" />
472                 <p class="description"><?php _e( 'If you would like to change the password type a new one. Otherwise leave this blank.' ); ?></p>
473         </td>
474 </tr>
475 <tr class="user-pass2-wrap">
476         <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
477         <td>
478         <input name="pass2" type="password" id="pass2" class="regular-text" size="16" value="" autocomplete="off" />
479         <p class="description"><?php _e( 'Type your new password again.' ); ?></p>
480         <br />
481         <div id="pass-strength-result"><?php _e( 'Strength indicator' ); ?></div>
482         <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p>
483         </td>
484 </tr>
485 <?php endif; ?>
486
487 <?php
488 if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?>
489         <tr class="user-sessions-wrap hide-if-no-js">
490                 <th>&nbsp;</th>
491                 <td aria-live="assertive">
492                         <div class="destroy-sessions"><button disabled class="button button-secondary"><?php _e( 'Log Out of All Other Sessions' ); ?></button></div>
493                         <p class="description">
494                                 <?php _e( 'You are only logged in at this location.' ); ?>
495                         </p>
496                 </td>
497         </tr>
498 <?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?>
499         <tr class="user-sessions-wrap hide-if-no-js">
500                 <th>&nbsp;</th>
501                 <td aria-live="assertive">
502                         <div class="destroy-sessions"><button class="button button-secondary" id="destroy-sessions"><?php _e( 'Log Out of All Other Sessions' ); ?></button></div>
503                         <p class="description">
504                                 <?php _e( 'Left your account logged in at a public computer? Lost your phone? This will log you out everywhere except your current browser.' ); ?>
505                         </p>
506                 </td>
507         </tr>
508 <?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?>
509         <tr class="user-sessions-wrap hide-if-no-js">
510                 <th>&nbsp;</th>
511                 <td>
512                         <p><button class="button button-secondary" id="destroy-sessions"><?php _e( 'Log Out of All Sessions' ); ?></button></p>
513                         <p class="description">
514                                 <?php
515                                 /* translators: 1: User's display name. */
516                                 printf( __( 'Log %s out of all sessions' ), $profileuser->display_name );
517                                 ?>
518                         </p>
519                 </td>
520         </tr>
521 <?php endif; ?>
522
523 </table>
524
525 <?php
526         if ( IS_PROFILE_PAGE ) {
527                 /**
528                  * Fires after the 'About Yourself' settings table on the 'Your Profile' editing screen.
529                  *
530                  * The action only fires if the current user is editing their own profile.
531                  *
532                  * @since 2.0.0
533                  *
534                  * @param WP_User $profileuser The current WP_User object.
535                  */
536                 do_action( 'show_user_profile', $profileuser );
537         } else {
538                 /**
539                  * Fires after the 'About the User' settings table on the 'Edit User' screen.
540                  *
541                  * @since 2.0.0
542                  *
543                  * @param WP_User $profileuser The current WP_User object.
544                  */
545                 do_action( 'edit_user_profile', $profileuser );
546         }
547 ?>
548
549 <?php
550 /**
551  * Filter whether to display additional capabilities for the user.
552  *
553  * The 'Additional Capabilities' section will only be enabled if
554  * the number of the user's capabilities exceeds their number of
555  * of roles.
556  *
557  * @since 2.8.0
558  *
559  * @param bool    $enable      Whether to display the capabilities. Default true.
560  * @param WP_User $profileuser The current WP_User object.
561  */
562 if ( count( $profileuser->caps ) > count( $profileuser->roles )
563         && apply_filters( 'additional_capabilities_display', true, $profileuser )
564 ) : ?>
565 <h3><?php _e( 'Additional Capabilities' ); ?></h3>
566 <table class="form-table">
567 <tr class="user-capabilities-wrap">
568         <th scope="row"><?php _e( 'Capabilities' ); ?></th>
569         <td>
570 <?php
571         $output = '';
572         foreach ( $profileuser->caps as $cap => $value ) {
573                 if ( ! $wp_roles->is_role( $cap ) ) {
574                         if ( '' != $output )
575                                 $output .= ', ';
576                         $output .= $value ? $cap : sprintf( __( 'Denied: %s' ), $cap );
577                 }
578         }
579         echo $output;
580 ?>
581         </td>
582 </tr>
583 </table>
584 <?php endif; ?>
585
586 <input type="hidden" name="action" value="update" />
587 <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($user_id); ?>" />
588
589 <?php submit_button( IS_PROFILE_PAGE ? __('Update Profile') : __('Update User') ); ?>
590
591 </form>
592 </div>
593 <?php
594 break;
595 }
596 ?>
597 <script type="text/javascript">
598         if (window.location.hash == '#password') {
599                 document.getElementById('pass1').focus();
600         }
601 </script>
602 <?php
603 include( ABSPATH . 'wp-admin/admin-footer.php');