/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 “account”) 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>' . __( 'You can select the language you wish to use while using the WordPress administration screen without affecting the language site visitors see.' ) . '</p>' . 
  42. '<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>' . 
  43. '<p>' . __( 'You can log out of other devices, such as your phone or a public computer, by clicking the Log Out Everywhere Else button.' ) . '</p>' . 
  44. '<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>' . 
  45. '<p>' . __('Remember to click the Update Profile button when you are finished.') . '</p>'; 
  46.  
  47. get_current_screen()->add_help_tab( array( 
  48. 'id' => 'overview',  
  49. 'title' => __('Overview'),  
  50. 'content' => $profile_help,  
  51. ) ); 
  52.  
  53. get_current_screen()->set_help_sidebar( 
  54. '<p><strong>' . __('For more information:') . '</strong></p>' . 
  55. '<p>' . __('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen">Documentation on User Profiles</a>') . '</p>' . 
  56. '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' 
  57. ); 
  58.  
  59. $wp_http_referer = remove_query_arg( array( 'update', 'delete_count', 'user_id' ), $wp_http_referer ); 
  60.  
  61. $user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ); 
  62.  
  63. /** 
  64. * Filters whether to allow administrators on Multisite to edit every user. 
  65. * 
  66. * Enabling the user editing form via this filter also hinges on the user holding 
  67. * the 'manage_network_users' cap, and the logged-in user not matching the user 
  68. * profile open for editing. 
  69. * 
  70. * The filter was introduced to replace the EDIT_ANY_USER constant. 
  71. * 
  72. * @since 3.0.0 
  73. * 
  74. * @param bool $allow Whether to allow editing of any user. Default true. 
  75. */ 
  76. if ( is_multisite() 
  77. && ! current_user_can( 'manage_network_users' ) 
  78. && $user_id != $current_user->ID 
  79. && ! apply_filters( 'enable_edit_any_user_configuration', true ) 
  80. ) { 
  81. wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); 
  82.  
  83. // Execute confirmed email change. See send_confirmation_on_profile_email(). 
  84. if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) { 
  85. $new_email = get_user_meta( $current_user->ID, '_new_email', true ); 
  86. if ( $new_email && hash_equals( $new_email[ 'hash' ], $_GET[ 'newuseremail' ] ) ) { 
  87. $user = new stdClass; 
  88. $user->ID = $current_user->ID; 
  89. $user->user_email = esc_html( trim( $new_email[ 'newemail' ] ) ); 
  90. if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) { 
  91. $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) ); 
  92. wp_update_user( $user ); 
  93. delete_user_meta( $current_user->ID, '_new_email' ); 
  94. wp_redirect( add_query_arg( array( 'updated' => 'true' ), self_admin_url( 'profile.php' ) ) ); 
  95. die(); 
  96. } else { 
  97. wp_redirect( add_query_arg( array( 'error' => 'new-email' ), self_admin_url( 'profile.php' ) ) ); 
  98. } elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' === $_GET['dismiss'] ) { 
  99. check_admin_referer( 'dismiss-' . $current_user->ID . '_new_email' ); 
  100. delete_user_meta( $current_user->ID, '_new_email' ); 
  101. wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) ); 
  102. die(); 
  103.  
  104. switch ($action) { 
  105. case 'update': 
  106.  
  107. check_admin_referer('update-user_' . $user_id); 
  108.  
  109. if ( !current_user_can('edit_user', $user_id) ) 
  110. wp_die(__('Sorry, you are not allowed to edit this user.')); 
  111.  
  112. if ( IS_PROFILE_PAGE ) { 
  113. /** 
  114. * Fires before the page loads on the 'Your Profile' editing screen. 
  115. * 
  116. * The action only fires if the current user is editing their own profile. 
  117. * 
  118. * @since 2.0.0 
  119. * 
  120. * @param int $user_id The user ID. 
  121. */ 
  122. do_action( 'personal_options_update', $user_id ); 
  123. } else { 
  124. /** 
  125. * Fires before the page loads on the 'Edit User' screen. 
  126. * 
  127. * @since 2.7.0 
  128. * 
  129. * @param int $user_id The user ID. 
  130. */ 
  131. do_action( 'edit_user_profile_update', $user_id ); 
  132.  
  133. // Update the email address in signups, if present. 
  134. if ( is_multisite() ) { 
  135. $user = get_userdata( $user_id ); 
  136.  
  137. 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 ) ) ) { 
  138. $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST[ 'email' ], $user_login ) ); 
  139.  
  140. // Update the user. 
  141. $errors = edit_user( $user_id ); 
  142.  
  143. // Grant or revoke super admin status if requested. 
  144. 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 ) ) { 
  145. empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id ); 
  146.  
  147. if ( !is_wp_error( $errors ) ) { 
  148. $redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) ); 
  149. if ( $wp_http_referer ) 
  150. $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect); 
  151. wp_redirect($redirect); 
  152. exit; 
  153.  
  154. default: 
  155. $profileuser = get_user_to_edit($user_id); 
  156.  
  157. if ( !current_user_can('edit_user', $user_id) ) 
  158. wp_die(__('Sorry, you are not allowed to edit this user.')); 
  159.  
  160. $sessions = WP_Session_Tokens::get_instance( $profileuser->ID ); 
  161.  
  162. include(ABSPATH . 'wp-admin/admin-header.php'); 
  163. ?> 
  164.  
  165. <?php if ( !IS_PROFILE_PAGE && is_super_admin( $profileuser->ID ) && current_user_can( 'manage_network_options' ) ) { ?> 
  166. <div class="updated"><p><strong><?php _e('Important:'); ?></strong> <?php _e('This user has super admin privileges.'); ?></p></div> 
  167. <?php } ?> 
  168. <?php if ( isset($_GET['updated']) ) : ?> 
  169. <div id="message" class="updated notice is-dismissible"> 
  170. <?php if ( IS_PROFILE_PAGE ) : ?> 
  171. <p><strong><?php _e('Profile updated.') ?></strong></p> 
  172. <?php else: ?> 
  173. <p><strong><?php _e('User updated.') ?></strong></p> 
  174. <?php endif; ?> 
  175. <?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?> 
  176. <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e('← Back to Users'); ?></a></p> 
  177. <?php endif; ?> 
  178. </div> 
  179. <?php endif; ?> 
  180. <?php if ( isset( $_GET['error'] ) ) : ?> 
  181. <div class="notice notice-error"> 
  182. <?php if ( 'new-email' == $_GET['error'] ) : ?> 
  183. <p><?php _e( 'Error while saving the new email address. Please try again.' ); ?></p> 
  184. <?php endif; ?> 
  185. </div> 
  186. <?php endif; ?> 
  187. <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?> 
  188. <div class="error"><p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p></div> 
  189. <?php endif; ?> 
  190.  
  191. <div class="wrap" id="profile-page"> 
  192. <h1> 
  193. <?php 
  194. echo esc_html( $title ); 
  195. if ( ! IS_PROFILE_PAGE ) { 
  196. if ( current_user_can( 'create_users' ) ) { ?> 
  197. <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a> 
  198. <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> 
  199. <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a> 
  200. <?php } 
  201. } ?> 
  202. </h1> 
  203. <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 
  204. /** 
  205. * Fires inside the your-profile form tag on the user editing screen. 
  206. * 
  207. * @since 3.0.0 
  208. */ 
  209. do_action( 'user_edit_form_tag' ); 
  210. ?>> 
  211. <?php wp_nonce_field('update-user_' . $user_id) ?> 
  212. <?php if ( $wp_http_referer ) : ?> 
  213. <input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" /> 
  214. <?php endif; ?> 
  215. <p> 
  216. <input type="hidden" name="from" value="profile" /> 
  217. <input type="hidden" name="checkuser_id" value="<?php echo get_current_user_id(); ?>" /> 
  218. </p> 
  219.  
  220. <h2><?php _e( 'Personal Options' ); ?></h2> 
  221.  
  222. <table class="form-table"> 
  223. <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?> 
  224. <tr class="user-rich-editing-wrap"> 
  225. <th scope="row"><?php _e( 'Visual Editor' ); ?></th> 
  226. <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> 
  227. </tr> 
  228. <?php endif; ?> 
  229. <?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?> 
  230. <tr class="user-admin-color-wrap"> 
  231. <th scope="row"><?php _e('Admin Color Scheme')?></th> 
  232. <td><?php 
  233. /** 
  234. * Fires in the 'Admin Color Scheme' section of the user editing screen. 
  235. * 
  236. * The section is only enabled if a callback is hooked to the action,  
  237. * and if there is more than one defined color scheme for the admin. 
  238. * 
  239. * @since 3.0.0 
  240. * @since 3.8.1 Added `$user_id` parameter. 
  241. * 
  242. * @param int $user_id The user ID. 
  243. */ 
  244. do_action( 'admin_color_scheme_picker', $user_id ); 
  245. ?></td> 
  246. </tr> 
  247. <?php 
  248. endif; // $_wp_admin_css_colors 
  249. if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?> 
  250. <tr class="user-comment-shortcuts-wrap"> 
  251. <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> 
  252. <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="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td> 
  253. </tr> 
  254. <?php endif; ?> 
  255. <tr class="show-admin-bar user-admin-bar-front-wrap"> 
  256. <th scope="row"><?php _e( 'Toolbar' ); ?></th> 
  257. <td><fieldset><legend class="screen-reader-text"><span><?php _e('Toolbar') ?></span></legend> 
  258. <label for="admin_bar_front"> 
  259. <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> /> 
  260. <?php _e( 'Show Toolbar when viewing site' ); ?></label><br /> 
  261. </fieldset> 
  262. </td> 
  263. </tr> 
  264.  
  265. <?php 
  266. $languages = get_available_languages(); 
  267. if ( $languages ) : ?> 
  268. <tr class="user-language-wrap"> 
  269. <th scope="row"> 
  270. <?php /** translators: The user language selection field label */ ?> 
  271. <label for="locale"><?php _e( 'Language' ); ?></label> 
  272. </th> 
  273. <td> 
  274. <?php 
  275. $user_locale = $profileuser->locale; 
  276.  
  277. if ( 'en_US' === $user_locale ) { 
  278. $user_locale = ''; 
  279. } elseif ( '' === $user_locale || ! in_array( $user_locale, $languages, true ) ) { 
  280. $user_locale = 'site-default'; 
  281.  
  282. wp_dropdown_languages( array( 
  283. 'name' => 'locale',  
  284. 'id' => 'locale',  
  285. 'selected' => $user_locale,  
  286. 'languages' => $languages,  
  287. 'show_available_translations' => false,  
  288. 'show_option_site_default' => true 
  289. ) ); 
  290. ?> 
  291. </td> 
  292. </tr> 
  293. <?php 
  294. endif; 
  295. ?> 
  296.  
  297. <?php 
  298. /** 
  299. * Fires at the end of the 'Personal Options' settings table on the user editing screen. 
  300. * 
  301. * @since 2.7.0 
  302. * 
  303. * @param WP_User $profileuser The current WP_User object. 
  304. */ 
  305. do_action( 'personal_options', $profileuser ); 
  306. ?> 
  307.  
  308. </table> 
  309. <?php 
  310. if ( IS_PROFILE_PAGE ) { 
  311. /** 
  312. * Fires after the 'Personal Options' settings table on the 'Your Profile' editing screen. 
  313. * 
  314. * The action only fires if the current user is editing their own profile. 
  315. * 
  316. * @since 2.0.0 
  317. * 
  318. * @param WP_User $profileuser The current WP_User object. 
  319. */ 
  320. do_action( 'profile_personal_options', $profileuser ); 
  321. ?> 
  322.  
  323. <h2><?php _e( 'Name' ); ?></h2> 
  324.  
  325. <table class="form-table"> 
  326. <tr class="user-user-login-wrap"> 
  327. <th><label for="user_login"><?php _e('Username'); ?></label></th> 
  328. <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> 
  329. </tr> 
  330.  
  331. <?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?> 
  332. <tr class="user-role-wrap"><th><label for="role"><?php _e('Role') ?></label></th> 
  333. <td><select name="role" id="role"> 
  334. <?php 
  335. // Compare user role against currently editable roles 
  336. $user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) ); 
  337. $user_role = reset( $user_roles ); 
  338.  
  339. // print the full list of roles with the primary one selected. 
  340. wp_dropdown_roles($user_role); 
  341.  
  342. // print the 'no role' option. Make it selected if the user has no role yet. 
  343. if ( $user_role ) 
  344. echo '<option value="">' . __('— No role for this site —') . '</option>'; 
  345. else 
  346. echo '<option value="" selected="selected">' . __('— No role for this site —') . '</option>'; 
  347. ?> 
  348. </select></td></tr> 
  349. <?php endif; //!IS_PROFILE_PAGE 
  350.  
  351. if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?> 
  352. <tr class="user-super-admin-wrap"><th><?php _e('Super Admin'); ?></th> 
  353. <td> 
  354. <?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) || ! is_super_admin( $profileuser->ID ) ) : ?> 
  355. <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> 
  356. <?php else : ?> 
  357. <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p> 
  358. <?php endif; ?> 
  359. </td></tr> 
  360. <?php } ?> 
  361.  
  362. <tr class="user-first-name-wrap"> 
  363. <th><label for="first_name"><?php _e('First Name') ?></label></th> 
  364. <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr($profileuser->first_name) ?>" class="regular-text" /></td> 
  365. </tr> 
  366.  
  367. <tr class="user-last-name-wrap"> 
  368. <th><label for="last_name"><?php _e('Last Name') ?></label></th> 
  369. <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr($profileuser->last_name) ?>" class="regular-text" /></td> 
  370. </tr> 
  371.  
  372. <tr class="user-nickname-wrap"> 
  373. <th><label for="nickname"><?php _e('Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> 
  374. <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></td> 
  375. </tr> 
  376.  
  377. <tr class="user-display-name-wrap"> 
  378. <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th> 
  379. <td> 
  380. <select name="display_name" id="display_name"> 
  381. <?php 
  382. $public_display = array(); 
  383. $public_display['display_nickname'] = $profileuser->nickname; 
  384. $public_display['display_username'] = $profileuser->user_login; 
  385.  
  386. if ( !empty($profileuser->first_name) ) 
  387. $public_display['display_firstname'] = $profileuser->first_name; 
  388.  
  389. if ( !empty($profileuser->last_name) ) 
  390. $public_display['display_lastname'] = $profileuser->last_name; 
  391.  
  392. if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { 
  393. $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; 
  394. $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; 
  395.  
  396. if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere 
  397. $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display; 
  398.  
  399. $public_display = array_map( 'trim', $public_display ); 
  400. $public_display = array_unique( $public_display ); 
  401.  
  402. foreach ( $public_display as $id => $item ) { 
  403. ?> 
  404. <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option> 
  405. <?php 
  406. ?> 
  407. </select> 
  408. </td> 
  409. </tr> 
  410. </table> 
  411.  
  412. <h2><?php _e( 'Contact Info' ); ?></h2> 
  413.  
  414. <table class="form-table"> 
  415. <tr class="user-email-wrap"> 
  416. <th><label for="email"><?php _e('Email'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> 
  417. <td><input type="email" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ) ?>" class="regular-text ltr" /> 
  418. <?php 
  419. $new_email = get_user_meta( $current_user->ID, '_new_email', true ); 
  420. if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : ?> 
  421. <div class="updated inline"> 
  422. <p><?php 
  423. printf( 
  424. /** translators: %s: new email */ 
  425. __( 'There is a pending change of your email to %s.' ),  
  426. '<code>' . esc_html( $new_email['newemail'] ) . '</code>' 
  427. ); 
  428. printf( 
  429. ' <a href="%1$s">%2$s</a>',  
  430. esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ),  
  431. __( 'Cancel' ) 
  432. ); 
  433. ?></p> 
  434. </div> 
  435. <?php endif; ?> 
  436. </td> 
  437. </tr> 
  438.  
  439. <tr class="user-url-wrap"> 
  440. <th><label for="url"><?php _e('Website') ?></label></th> 
  441. <td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ) ?>" class="regular-text code" /></td> 
  442. </tr> 
  443.  
  444. <?php 
  445. foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) { 
  446. ?> 
  447. <tr class="user-<?php echo $name; ?>-wrap"> 
  448. <th><label for="<?php echo $name; ?>"> 
  449. <?php 
  450. /** 
  451. * Filters a user contactmethod label. 
  452. * 
  453. * The dynamic portion of the filter hook, `$name`, refers to 
  454. * each of the keys in the contactmethods array. 
  455. * 
  456. * @since 2.9.0 
  457. * 
  458. * @param string $desc The translatable label for the contactmethod. 
  459. */ 
  460. echo apply_filters( "user_{$name}_label", $desc ); 
  461. ?> 
  462. </label></th> 
  463. <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td> 
  464. </tr> 
  465. <?php 
  466. ?> 
  467. </table> 
  468.  
  469. <h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2> 
  470.  
  471. <table class="form-table"> 
  472. <tr class="user-description-wrap"> 
  473. <th><label for="description"><?php _e('Biographical Info'); ?></label></th> 
  474. <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea> 
  475. <p class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p></td> 
  476. </tr> 
  477.  
  478. <?php if ( get_option( 'show_avatars' ) ) : ?> 
  479. <tr class="user-profile-picture"> 
  480. <th><?php _e( 'Profile Picture' ); ?></th> 
  481. <td> 
  482. <?php echo get_avatar( $user_id ); ?> 
  483. <p class="description"><?php 
  484. if ( IS_PROFILE_PAGE ) { 
  485. /** translators: %s: Gravatar URL */ 
  486. $description = sprintf( __( 'You can change your profile picture on <a href="%s">Gravatar</a>.' ),  
  487. __( 'https://en.gravatar.com/' ) 
  488. ); 
  489. } else { 
  490. $description = ''; 
  491.  
  492. /** 
  493. * Filters the user profile picture description displayed under the Gravatar. 
  494. * 
  495. * @since 4.4.0 
  496. * @since 4.7.0 Added the `$profileuser` parameter. 
  497. * 
  498. * @param string $description The description that will be printed. 
  499. * @param WP_User $profileuser The current WP_User object. 
  500. */ 
  501. echo apply_filters( 'user_profile_picture_description', $description, $profileuser ); 
  502. ?></p> 
  503. </td> 
  504. </tr> 
  505. <?php endif; ?> 
  506.  
  507. <?php 
  508. /** 
  509. * Filters the display of the password fields. 
  510. * 
  511. * @since 1.5.1 
  512. * @since 2.8.0 Added the `$profileuser` parameter. 
  513. * @since 4.4.0 Now evaluated only in user-edit.php. 
  514. * 
  515. * @param bool $show Whether to show the password fields. Default true. 
  516. * @param WP_User $profileuser User object for the current user to edit. 
  517. */ 
  518. if ( $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser ) ) : 
  519. ?> 
  520. </table> 
  521.  
  522. <h2><?php _e( 'Account Management' ); ?></h2> 
  523. <table class="form-table"> 
  524. <tr id="password" class="user-pass1-wrap"> 
  525. <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th> 
  526. <td> 
  527. <input class="hidden" value=" " /><!-- #24364 workaround --> 
  528. <button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Generate Password' ); ?></button> 
  529. <div class="wp-pwd hide-if-js"> 
  530. <span class="password-input-wrapper"> 
  531. <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" /> 
  532. </span> 
  533. <button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> 
  534. <span class="dashicons dashicons-hidden"></span> 
  535. <span class="text"><?php _e( 'Hide' ); ?></span> 
  536. </button> 
  537. <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>"> 
  538. <span class="text"><?php _e( 'Cancel' ); ?></span> 
  539. </button> 
  540. <div style="display:none" id="pass-strength-result" aria-live="polite"></div> 
  541. </div> 
  542. </td> 
  543. </tr> 
  544. <tr class="user-pass2-wrap hide-if-js"> 
  545. <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th> 
  546. <td> 
  547. <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" /> 
  548. <p class="description"><?php _e( 'Type your new password again.' ); ?></p> 
  549. </td> 
  550. </tr> 
  551. <tr class="pw-weak"> 
  552. <th><?php _e( 'Confirm Password' ); ?></th> 
  553. <td> 
  554. <label> 
  555. <input type="checkbox" name="pw_weak" class="pw-checkbox" /> 
  556. <span id="pw-weak-text-label"><?php _e( 'Confirm use of potentially weak password' ); ?></span> 
  557. </label> 
  558. </td> 
  559. </tr> 
  560. <?php endif; ?> 
  561.  
  562. <?php 
  563. if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?> 
  564. <tr class="user-sessions-wrap hide-if-no-js"> 
  565. <th><?php _e( 'Sessions' ); ?></th> 
  566. <td aria-live="assertive"> 
  567. <div class="destroy-sessions"><button type="button" disabled class="button"><?php _e( 'Log Out Everywhere Else' ); ?></button></div> 
  568. <p class="description"> 
  569. <?php _e( 'You are only logged in at this location.' ); ?> 
  570. </p> 
  571. </td> 
  572. </tr> 
  573. <?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?> 
  574. <tr class="user-sessions-wrap hide-if-no-js"> 
  575. <th><?php _e( 'Sessions' ); ?></th> 
  576. <td aria-live="assertive"> 
  577. <div class="destroy-sessions"><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere Else' ); ?></button></div> 
  578. <p class="description"> 
  579. <?php _e( 'Did you lose your phone or leave your account logged in at a public computer? You can log out everywhere else, and stay logged in here.' ); ?> 
  580. </p> 
  581. </td> 
  582. </tr> 
  583. <?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?> 
  584. <tr class="user-sessions-wrap hide-if-no-js"> 
  585. <th><?php _e( 'Sessions' ); ?></th> 
  586. <td> 
  587. <p><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere' ); ?></button></p> 
  588. <p class="description"> 
  589. <?php 
  590. /** translators: 1: User's display name. */ 
  591. printf( __( 'Log %s out of all locations.' ), $profileuser->display_name ); 
  592. ?> 
  593. </p> 
  594. </td> 
  595. </tr> 
  596. <?php endif; ?> 
  597.  
  598. </table> 
  599.  
  600. <?php 
  601. if ( IS_PROFILE_PAGE ) { 
  602. /** 
  603. * Fires after the 'About Yourself' settings table on the 'Your Profile' editing screen. 
  604. * 
  605. * The action only fires if the current user is editing their own profile. 
  606. * 
  607. * @since 2.0.0 
  608. * 
  609. * @param WP_User $profileuser The current WP_User object. 
  610. */ 
  611. do_action( 'show_user_profile', $profileuser ); 
  612. } else { 
  613. /** 
  614. * Fires after the 'About the User' settings table on the 'Edit User' screen. 
  615. * 
  616. * @since 2.0.0 
  617. * 
  618. * @param WP_User $profileuser The current WP_User object. 
  619. */ 
  620. do_action( 'edit_user_profile', $profileuser ); 
  621. ?> 
  622.  
  623. <?php 
  624. /** 
  625. * Filters whether to display additional capabilities for the user. 
  626. * 
  627. * The 'Additional Capabilities' section will only be enabled if 
  628. * the number of the user's capabilities exceeds their number of 
  629. * roles. 
  630. * 
  631. * @since 2.8.0 
  632. * 
  633. * @param bool $enable Whether to display the capabilities. Default true. 
  634. * @param WP_User $profileuser The current WP_User object. 
  635. */ 
  636. if ( count( $profileuser->caps ) > count( $profileuser->roles ) 
  637. && apply_filters( 'additional_capabilities_display', true, $profileuser ) 
  638. ) : ?> 
  639. <h2><?php _e( 'Additional Capabilities' ); ?></h2> 
  640. <table class="form-table"> 
  641. <tr class="user-capabilities-wrap"> 
  642. <th scope="row"><?php _e( 'Capabilities' ); ?></th> 
  643. <td> 
  644. <?php 
  645. $output = ''; 
  646. foreach ( $profileuser->caps as $cap => $value ) { 
  647. if ( ! $wp_roles->is_role( $cap ) ) { 
  648. if ( '' != $output ) 
  649. $output .= ', '; 
  650. $output .= $value ? $cap : sprintf( __( 'Denied: %s' ), $cap ); 
  651. echo $output; 
  652. ?> 
  653. </td> 
  654. </tr> 
  655. </table> 
  656. <?php endif; ?> 
  657.  
  658. <input type="hidden" name="action" value="update" /> 
  659. <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($user_id); ?>" /> 
  660.  
  661. <?php submit_button( IS_PROFILE_PAGE ? __('Update Profile') : __('Update User') ); ?> 
  662.  
  663. </form> 
  664. </div> 
  665. <?php 
  666. break; 
  667. ?> 
  668. <script type="text/javascript"> 
  669. if (window.location.hash == '#password') { 
  670. document.getElementById('pass1').focus(); 
  671. </script> 
  672. <?php 
  673. include( ABSPATH . 'wp-admin/admin-footer.php'); 
.