| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Edit user administration panel. 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 /** WordPress Administration Bootstrap */ 10 require_once __DIR__ . '/admin.php'; 11 12 /** WordPress Translation Installation API */ 13 require_once ABSPATH . 'wp-admin/includes/translation-install.php'; 14 15 $action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : ''; 16 $user_id = ! empty( $_REQUEST['user_id'] ) ? absint( $_REQUEST['user_id'] ) : 0; 17 $wp_http_referer = ! empty( $_REQUEST['wp_http_referer'] ) ? sanitize_url( $_REQUEST['wp_http_referer'] ) : ''; 18 19 $current_user = wp_get_current_user(); 20 21 if ( ! defined( 'IS_PROFILE_PAGE' ) ) { 22 define( 'IS_PROFILE_PAGE', ( $user_id === $current_user->ID ) ); 23 } 24 25 if ( ! $user_id && IS_PROFILE_PAGE ) { 26 $user_id = $current_user->ID; 27 } elseif ( ! $user_id && ! IS_PROFILE_PAGE ) { 28 wp_die( __( 'Invalid user ID.' ) ); 29 } elseif ( ! get_userdata( $user_id ) ) { 30 wp_die( __( 'Invalid user ID.' ) ); 31 } 32 33 wp_enqueue_script( 'user-profile' ); 34 35 if ( wp_is_application_passwords_available_for_user( $user_id ) ) { 36 wp_enqueue_script( 'application-passwords' ); 37 } 38 39 if ( IS_PROFILE_PAGE ) { 40 // Used in the HTML title tag. 41 $title = __( 'Profile' ); 42 } else { 43 // Used in the HTML title tag. 44 /* translators: %s: User's display name. */ 45 $title = __( 'Edit User %s' ); 46 } 47 48 if ( current_user_can( 'edit_users' ) && ! IS_PROFILE_PAGE ) { 49 $submenu_file = 'users.php'; 50 } else { 51 $submenu_file = 'profile.php'; 52 } 53 54 if ( current_user_can( 'edit_users' ) && ! is_user_admin() ) { 55 $parent_file = 'users.php'; 56 } else { 57 $parent_file = 'profile.php'; 58 } 59 60 $profile_help = '<p>' . __( 'Your profile contains information about you (your “account”) as well as some personal options related to using WordPress.' ) . '</p>' . 61 '<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>' . 62 '<p>' . __( 'You can select the language you wish to use while using the WordPress administration screen without affecting the language site visitors see.' ) . '</p>' . 63 '<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>' . 64 '<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>' . 65 '<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>' . 66 '<p>' . __( 'Remember to click the Update Profile button when you are finished.' ) . '</p>'; 67 68 get_current_screen()->add_help_tab( 69 array( 70 'id' => 'overview', 71 'title' => __( 'Overview' ), 72 'content' => $profile_help, 73 ) 74 ); 75 76 get_current_screen()->set_help_sidebar( 77 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 78 '<p>' . __( '<a href="https://wordpress.org/documentation/article/users-your-profile-screen/">Documentation on User Profiles</a>' ) . '</p>' . 79 '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>' 80 ); 81 82 $wp_http_referer = remove_query_arg( array( 'update', 'delete_count', 'user_id' ), $wp_http_referer ); 83 84 $user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ); 85 86 /** 87 * Filters whether to allow administrators on Multisite to edit every user. 88 * 89 * Enabling the user editing form via this filter also hinges on the user holding 90 * the 'manage_network_users' cap, and the logged-in user not matching the user 91 * profile open for editing. 92 * 93 * The filter was introduced to replace the EDIT_ANY_USER constant. 94 * 95 * @since 3.0.0 96 * 97 * @param bool $allow Whether to allow editing of any user. Default true. 98 */ 99 if ( is_multisite() 100 && ! current_user_can( 'manage_network_users' ) 101 && $user_id !== $current_user->ID 102 && ! apply_filters( 'enable_edit_any_user_configuration', true ) 103 ) { 104 wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); 105 } 106 107 // Execute confirmed email change. See send_confirmation_on_profile_email(). 108 if ( IS_PROFILE_PAGE && isset( $_GET['newuseremail'] ) && $current_user->ID ) { 109 $new_email = get_user_meta( $current_user->ID, '_new_email', true ); 110 if ( $new_email && hash_equals( $new_email['hash'], $_GET['newuseremail'] ) ) { 111 $user = new stdClass(); 112 $user->ID = $current_user->ID; 113 $user->user_email = esc_html( trim( $new_email['newemail'] ) ); 114 if ( is_multisite() && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) { 115 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) ); 116 } 117 wp_update_user( $user ); 118 delete_user_meta( $current_user->ID, '_new_email' ); 119 wp_redirect( add_query_arg( array( 'updated' => 'true' ), self_admin_url( 'profile.php' ) ) ); 120 die(); 121 } else { 122 wp_redirect( add_query_arg( array( 'error' => 'new-email' ), self_admin_url( 'profile.php' ) ) ); 123 } 124 } elseif ( IS_PROFILE_PAGE && ! empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' === $_GET['dismiss'] ) { 125 check_admin_referer( 'dismiss-' . $current_user->ID . '_new_email' ); 126 delete_user_meta( $current_user->ID, '_new_email' ); 127 wp_redirect( add_query_arg( array( 'updated' => 'true' ), self_admin_url( 'profile.php' ) ) ); 128 die(); 129 } 130 131 switch ( $action ) { 132 case 'update': 133 check_admin_referer( 'update-user_' . $user_id ); 134 135 if ( ! current_user_can( 'edit_user', $user_id ) ) { 136 wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); 137 } 138 139 if ( IS_PROFILE_PAGE ) { 140 /** 141 * Fires before the page loads on the 'Profile' editing screen. 142 * 143 * The action only fires if the current user is editing their own profile. 144 * 145 * @since 2.0.0 146 * 147 * @param int $user_id The user ID. 148 */ 149 do_action( 'personal_options_update', $user_id ); 150 } else { 151 /** 152 * Fires before the page loads on the 'Edit User' screen. 153 * 154 * @since 2.7.0 155 * 156 * @param int $user_id The user ID. 157 */ 158 do_action( 'edit_user_profile_update', $user_id ); 159 } 160 161 // Update the email address in signups, if present. 162 if ( is_multisite() ) { 163 $user = get_userdata( $user_id ); 164 165 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 ) ) ) { 166 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST['email'], $user_login ) ); 167 } 168 } 169 170 // Update the user. 171 $errors = edit_user( $user_id ); 172 173 // Grant or revoke super admin status if requested. 174 if ( is_multisite() && is_network_admin() 175 && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) 176 && ! isset( $super_admins ) && empty( $_POST['super_admin'] ) === is_super_admin( $user_id ) 177 ) { 178 empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id ); 179 } 180 181 if ( ! is_wp_error( $errors ) ) { 182 $redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) ); 183 if ( $wp_http_referer ) { 184 $redirect = add_query_arg( 'wp_http_referer', urlencode( $wp_http_referer ), $redirect ); 185 } 186 wp_redirect( $redirect ); 187 exit; 188 } 189 190 // Intentional fall-through to display $errors. 191 default: 192 $profile_user = get_user_to_edit( $user_id ); 193 194 if ( ! current_user_can( 'edit_user', $user_id ) ) { 195 wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); 196 } 197 198 $title = sprintf( $title, $profile_user->display_name ); 199 $sessions = WP_Session_Tokens::get_instance( $profile_user->ID ); 200 201 require_once ABSPATH . 'wp-admin/admin-header.php'; 202 ?> 203 204 <?php 205 if ( ! IS_PROFILE_PAGE && is_super_admin( $profile_user->ID ) && current_user_can( 'manage_network_options' ) ) : 206 $message = '<strong>' . __( 'Important:' ) . '</strong> ' . __( 'This user has super admin privileges.' ); 207 wp_admin_notice( 208 $message, 209 array( 210 'type' => 'info', 211 ) 212 ); 213 endif; 214 215 if ( isset( $_GET['updated'] ) ) : 216 if ( IS_PROFILE_PAGE ) : 217 $message = '<p><strong>' . __( 'Profile updated.' ) . '</strong></p>'; 218 else : 219 $message = '<p><strong>' . __( 'User updated.' ) . '</strong></p>'; 220 endif; 221 if ( $wp_http_referer && ! str_contains( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : 222 $message .= sprintf( 223 '<p><a href="%1$s">%2$s</a></p>', 224 esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), self_admin_url( 'users.php' ) ) ), 225 __( '← Go to Users' ) 226 ); 227 endif; 228 wp_admin_notice( 229 $message, 230 array( 231 'id' => 'message', 232 'dismissible' => true, 233 'additional_classes' => array( 'updated' ), 234 'paragraph_wrap' => false, 235 ) 236 ); 237 endif; 238 239 if ( isset( $_GET['error'] ) ) : 240 $message = ''; 241 if ( 'new-email' === $_GET['error'] ) : 242 $message = __( 'Error while saving the new email address. Please try again.' ); 243 endif; 244 wp_admin_notice( 245 $message, 246 array( 247 'type' => 'error', 248 ) 249 ); 250 endif; 251 252 if ( isset( $errors ) && is_wp_error( $errors ) ) { 253 wp_admin_notice( 254 implode( "</p>\n<p>", $errors->get_error_messages() ), 255 array( 256 'additional_classes' => array( 'error' ), 257 ) 258 ); 259 } 260 ?> 261 262 <div class="wrap" id="profile-page"> 263 <h1 class="wp-heading-inline"> 264 <?php echo esc_html( $title ); ?> 265 </h1> 266 267 <?php if ( ! IS_PROFILE_PAGE ) : ?> 268 <?php if ( current_user_can( 'create_users' ) ) : ?> 269 <a href="user-new.php" class="page-title-action"><?php echo esc_html__( 'Add User' ); ?></a> 270 <?php elseif ( is_multisite() && current_user_can( 'promote_users' ) ) : ?> 271 <a href="user-new.php" class="page-title-action"><?php echo esc_html__( 'Add Existing User' ); ?></a> 272 <?php endif; ?> 273 <?php endif; ?> 274 275 <hr class="wp-header-end"> 276 277 <form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post" novalidate="novalidate" 278 <?php 279 /** 280 * Fires inside the your-profile form tag on the user editing screen. 281 * 282 * @since 3.0.0 283 */ 284 do_action( 'user_edit_form_tag' ); 285 ?> 286 > 287 <?php wp_nonce_field( 'update-user_' . $user_id ); ?> 288 <?php if ( $wp_http_referer ) : ?> 289 <input type="hidden" name="wp_http_referer" value="<?php echo esc_url( $wp_http_referer ); ?>" /> 290 <?php endif; ?> 291 <p> 292 <input type="hidden" name="from" value="profile" /> 293 <input type="hidden" name="checkuser_id" value="<?php echo get_current_user_id(); ?>" /> 294 </p> 295 296 <h2><?php _e( 'Personal Options' ); ?></h2> 297 298 <table class="form-table" role="presentation"> 299 <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) && 'false' === $profile_user->rich_editing ) : ?> 300 <tr class="user-rich-editing-wrap"> 301 <th scope="row"><?php _e( 'Visual Editor' ); ?></th> 302 <td> 303 <label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php checked( 'false', $profile_user->rich_editing ); ?> /> 304 <?php _e( 'Disable the visual editor when writing' ); ?> 305 </label> 306 </td> 307 </tr> 308 <?php endif; ?> 309 310 <?php 311 $show_syntax_highlighting_preference = ( 312 // For Custom HTML widget and Additional CSS in Customizer. 313 user_can( $profile_user, 'edit_theme_options' ) 314 || 315 // Edit plugins. 316 user_can( $profile_user, 'edit_plugins' ) 317 || 318 // Edit themes. 319 user_can( $profile_user, 'edit_themes' ) 320 ); 321 ?> 322 323 <?php if ( $show_syntax_highlighting_preference ) : ?> 324 <tr class="user-syntax-highlighting-wrap"> 325 <th scope="row"><?php _e( 'Syntax Highlighting' ); ?></th> 326 <td> 327 <label for="syntax_highlighting"><input name="syntax_highlighting" type="checkbox" id="syntax_highlighting" value="false" <?php checked( 'false', $profile_user->syntax_highlighting ); ?> /> 328 <?php _e( 'Disable syntax highlighting when editing code' ); ?> 329 </label> 330 </td> 331 </tr> 332 <?php endif; ?> 333 334 <?php if ( count( $_wp_admin_css_colors ) > 1 && has_action( 'admin_color_scheme_picker' ) ) : ?> 335 <tr class="user-admin-color-wrap"> 336 <th scope="row"><?php _e( 'Administration Color Scheme' ); ?></th> 337 <td> 338 <?php 339 /** 340 * Fires in the 'Administration Color Scheme' section of the user editing screen. 341 * 342 * The section is only enabled if a callback is hooked to the action, 343 * and if there is more than one defined color scheme for the admin. 344 * 345 * @since 3.0.0 346 * @since 3.8.1 Added `$user_id` parameter. 347 * 348 * @param int $user_id The user ID. 349 */ 350 do_action( 'admin_color_scheme_picker', $user_id ); 351 ?> 352 </td> 353 </tr> 354 <?php endif; // End if count ( $_wp_admin_css_colors ) > 1 ?> 355 356 <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?> 357 <tr class="user-comment-shortcuts-wrap"> 358 <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> 359 <td> 360 <label for="comment_shortcuts"> 361 <input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php checked( 'true', $profile_user->comment_shortcuts ); ?> /> 362 <?php _e( 'Enable keyboard shortcuts for comment moderation.' ); ?> 363 </label> 364 <?php _e( '<a href="https://wordpress.org/documentation/article/keyboard-shortcuts-classic-editor/#keyboard-shortcuts-for-comments">Documentation on Keyboard Shortcuts</a>' ); ?> 365 </td> 366 </tr> 367 <?php endif; ?> 368 369 <tr class="show-admin-bar user-admin-bar-front-wrap"> 370 <th scope="row"><?php _e( 'Toolbar' ); ?></th> 371 <td> 372 <label for="admin_bar_front"> 373 <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profile_user->ID ) ); ?> /> 374 <?php _e( 'Show Toolbar when viewing site' ); ?> 375 </label><br /> 376 </td> 377 </tr> 378 379 <?php if ( user_can( $profile_user, 'upload_files' ) ) : ?> 380 <tr class="user-infinite-scrolling-wrap"> 381 <th scope="row"><?php _e( 'Infinite Scrolling' ); ?></th> 382 <td> 383 <label for="infinite_scrolling"><input name="infinite_scrolling" type="checkbox" id="infinite_scrolling" value="false" <?php checked( 'false', $profile_user->infinite_scrolling ); ?> /> 384 <?php _e( 'Disable infinite scrolling in the Media Library grid view' ); ?> 385 </label> 386 </td> 387 </tr> 388 <?php endif; ?> 389 390 <?php 391 $languages = get_available_languages(); 392 $can_install_translations = current_user_can( 'install_languages' ) && wp_can_install_language_pack(); 393 ?> 394 <?php if ( $languages || $can_install_translations ) : ?> 395 <tr class="user-language-wrap"> 396 <th scope="row"> 397 <?php /* translators: The user language selection field label. */ ?> 398 <label for="locale"><?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label> 399 </th> 400 <td> 401 <?php 402 $user_locale = $profile_user->locale; 403 404 if ( 'en_US' === $user_locale ) { 405 $user_locale = ''; 406 } elseif ( '' === $user_locale || ! in_array( $user_locale, $languages, true ) ) { 407 $user_locale = 'site-default'; 408 } 409 410 wp_dropdown_languages( 411 array( 412 'name' => 'locale', 413 'id' => 'locale', 414 'selected' => $user_locale, 415 'languages' => $languages, 416 'show_available_translations' => $can_install_translations, 417 'show_option_site_default' => true, 418 ) 419 ); 420 ?> 421 </td> 422 </tr> 423 <?php endif; ?> 424 425 <?php 426 /** 427 * Fires at the end of the 'Personal Options' settings table on the user editing screen. 428 * 429 * @since 2.7.0 430 * 431 * @param WP_User $profile_user The current WP_User object. 432 */ 433 do_action( 'personal_options', $profile_user ); 434 ?> 435 436 </table> 437 <?php 438 if ( IS_PROFILE_PAGE ) { 439 /** 440 * Fires after the 'Personal Options' settings table on the 'Profile' editing screen. 441 * 442 * The action only fires if the current user is editing their own profile. 443 * 444 * @since 2.0.0 445 * 446 * @param WP_User $profile_user The current WP_User object. 447 */ 448 do_action( 'profile_personal_options', $profile_user ); 449 } 450 ?> 451 452 <h2><?php _e( 'Name' ); ?></h2> 453 454 <table class="form-table" role="presentation"> 455 <tr class="user-user-login-wrap"> 456 <th><label for="user_login"><?php _e( 'Username' ); ?></label></th> 457 <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr( $profile_user->user_login ); ?>" readonly="readonly" class="regular-text ltr" /> <span class="description"><?php _e( 'Usernames cannot be changed.' ); ?></span></td> 458 </tr> 459 460 <?php if ( ! IS_PROFILE_PAGE && ! is_network_admin() && current_user_can( 'promote_user', $profile_user->ID ) ) : ?> 461 <tr class="user-role-wrap"> 462 <th><label for="role"><?php _e( 'Role' ); ?></label></th> 463 <td> 464 <select name="role" id="role"> 465 <?php 466 // Compare user role against currently editable roles. 467 $user_roles = array_intersect( array_values( $profile_user->roles ), array_keys( get_editable_roles() ) ); 468 $user_role = reset( $user_roles ); 469 470 // Print the full list of roles with the primary one selected. 471 wp_dropdown_roles( $user_role ); 472 473 // Print the 'no role' option. Make it selected if the user has no role yet. 474 if ( $user_role ) { 475 echo '<option value="">' . __( '— No role for this site —' ) . '</option>'; 476 } else { 477 echo '<option value="" selected="selected">' . __( '— No role for this site —' ) . '</option>'; 478 } 479 ?> 480 </select> 481 </td> 482 </tr> 483 <?php endif; // End if ! IS_PROFILE_PAGE. ?> 484 485 <?php if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && ! isset( $super_admins ) ) : ?> 486 <tr class="user-super-admin-wrap"> 487 <th><?php _e( 'Super Admin' ); ?></th> 488 <td> 489 <p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profile_user->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p> 490 </td> 491 </tr> 492 <?php endif; ?> 493 494 <tr class="user-first-name-wrap"> 495 <th><label for="first_name"><?php _e( 'First Name' ); ?></label></th> 496 <td> 497 <?php if ( IS_PROFILE_PAGE ) : ?> 498 <input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profile_user->first_name ); ?>" autocomplete="given-name" class="regular-text" /> 499 <?php else : ?> 500 <input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profile_user->first_name ); ?>" class="regular-text" /> 501 <?php endif; ?> 502 </td> 503 </tr> 504 505 <tr class="user-last-name-wrap"> 506 <th><label for="last_name"><?php _e( 'Last Name' ); ?></label></th> 507 <td> 508 <?php if ( IS_PROFILE_PAGE ) : ?> 509 <input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profile_user->last_name ); ?>" autocomplete="family-name" class="regular-text" /> 510 <?php else : ?> 511 <input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profile_user->last_name ); ?>" class="regular-text" /> 512 <?php endif; ?> 513 </td> 514 </tr> 515 516 <tr class="user-nickname-wrap"> 517 <th><label for="nickname"><?php _e( 'Nickname' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> 518 <td> 519 <?php if ( IS_PROFILE_PAGE ) : ?> 520 <input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profile_user->nickname ); ?>" autocomplete="nickname" class="regular-text" /> 521 <?php else : ?> 522 <input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profile_user->nickname ); ?>" class="regular-text" /> 523 <?php endif; ?> 524 </td> 525 </tr> 526 527 <tr class="user-display-name-wrap"> 528 <th> 529 <label for="display_name"><?php _e( 'Display name publicly as' ); ?></label> 530 </th> 531 <td> 532 <select name="display_name" id="display_name"> 533 <?php 534 $public_display = array(); 535 $public_display['display_nickname'] = $profile_user->nickname; 536 $public_display['display_username'] = $profile_user->user_login; 537 538 if ( ! empty( $profile_user->first_name ) ) { 539 $public_display['display_firstname'] = $profile_user->first_name; 540 } 541 542 if ( ! empty( $profile_user->last_name ) ) { 543 $public_display['display_lastname'] = $profile_user->last_name; 544 } 545 546 if ( ! empty( $profile_user->first_name ) && ! empty( $profile_user->last_name ) ) { 547 $public_display['display_firstlast'] = $profile_user->first_name . ' ' . $profile_user->last_name; 548 $public_display['display_lastfirst'] = $profile_user->last_name . ' ' . $profile_user->first_name; 549 } 550 551 if ( ! in_array( $profile_user->display_name, $public_display, true ) ) { // Only add this if it isn't duplicated elsewhere. 552 $public_display = array( 'display_displayname' => $profile_user->display_name ) + $public_display; 553 } 554 555 $public_display = array_map( 'trim', $public_display ); 556 $public_display = array_unique( $public_display ); 557 558 ?> 559 <?php foreach ( $public_display as $id => $item ) : ?> 560 <option <?php selected( $profile_user->display_name, $item ); ?>><?php echo $item; ?></option> 561 <?php endforeach; ?> 562 </select> 563 </td> 564 </tr> 565 </table> 566 567 <h2><?php _e( 'Contact Info' ); ?></h2> 568 569 <table class="form-table" role="presentation"> 570 <tr class="user-email-wrap"> 571 <th><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> 572 <td> 573 <?php if ( $profile_user->ID === $current_user->ID ) : ?> 574 <input type="email" name="email" id="email" aria-describedby="email-description" value="<?php echo esc_attr( $profile_user->user_email ); ?>" autocomplete="email" class="regular-text ltr" /> 575 <p class="description" id="email-description"> 576 <?php _e( 'If you change this, an email will be sent at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?> 577 </p> 578 <?php else : ?> 579 <input type="email" name="email" id="email" value="<?php echo esc_attr( $profile_user->user_email ); ?>" class="regular-text ltr" /> 580 <?php endif; ?> 581 582 <?php 583 $new_email = get_user_meta( $current_user->ID, '_new_email', true ); 584 if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) : 585 586 $pending_change_message = sprintf( 587 /* translators: %s: New email. */ 588 __( 'There is a pending change of your email to %s.' ), 589 '<code>' . esc_html( $new_email['newemail'] ) . '</code>' 590 ); 591 $pending_change_message .= sprintf( 592 ' <a href="%1$s">%2$s</a>', 593 esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ), 594 __( 'Cancel' ) 595 ); 596 wp_admin_notice( 597 $pending_change_message, 598 array( 599 'additional_classes' => array( 'updated', 'inline' ), 600 ) 601 ); 602 endif; 603 ?> 604 </td> 605 </tr> 606 607 <tr class="user-url-wrap"> 608 <th><label for="url"><?php _e( 'Website' ); ?></label></th> 609 <td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profile_user->user_url ); ?>" class="regular-text code" /></td> 610 </tr> 611 612 <?php foreach ( wp_get_user_contact_methods( $profile_user ) as $name => $desc ) : ?> 613 <tr class="user-<?php echo $name; ?>-wrap"> 614 <th> 615 <label for="<?php echo $name; ?>"> 616 <?php 617 /** 618 * Filters a user contactmethod label. 619 * 620 * The dynamic portion of the hook name, `$name`, refers to 621 * each of the keys in the contact methods array. 622 * 623 * @since 2.9.0 624 * 625 * @param string $desc The translatable label for the contact method. 626 */ 627 echo apply_filters( "user_{$name}_label", $desc ); 628 ?> 629 </label> 630 </th> 631 <td> 632 <input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profile_user->$name ); ?>" class="regular-text" /> 633 </td> 634 </tr> 635 <?php endforeach; ?> 636 </table> 637 638 <h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2> 639 640 <table class="form-table" role="presentation"> 641 <tr class="user-description-wrap"> 642 <th><label for="description"><?php _e( 'Biographical Info' ); ?></label></th> 643 <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profile_user->description; // textarea_escaped ?></textarea> 644 <p class="description"><?php _e( 'Share a little biographical information to fill out your profile. This may be shown publicly.' ); ?></p></td> 645 </tr> 646 647 <?php if ( get_option( 'show_avatars' ) ) : ?> 648 <tr class="user-profile-picture"> 649 <th><?php _e( 'Profile Picture' ); ?></th> 650 <td> 651 <?php echo get_avatar( $user_id ); ?> 652 <p class="description"> 653 <?php 654 if ( IS_PROFILE_PAGE ) { 655 $description = sprintf( 656 /* translators: %s: Gravatar URL. */ 657 __( '<a href="%s">You can change your profile picture on Gravatar</a>.' ), 658 /* translators: The localized Gravatar URL. */ 659 __( 'https://gravatar.com/' ) 660 ); 661 } else { 662 $description = ''; 663 } 664 665 /** 666 * Filters the user profile picture description displayed under the Gravatar. 667 * 668 * @since 4.4.0 669 * @since 4.7.0 Added the `$profile_user` parameter. 670 * 671 * @param string $description The description that will be printed. 672 * @param WP_User $profile_user The current WP_User object. 673 */ 674 echo apply_filters( 'user_profile_picture_description', $description, $profile_user ); 675 ?> 676 </p> 677 </td> 678 </tr> 679 <?php endif; ?> 680 <?php 681 /** 682 * Filters the display of the password fields. 683 * 684 * @since 1.5.1 685 * @since 2.8.0 Added the `$profile_user` parameter. 686 * @since 4.4.0 Now evaluated only in user-edit.php. 687 * 688 * @param bool $show Whether to show the password fields. Default true. 689 * @param WP_User $profile_user User object for the current user to edit. 690 */ 691 $show_password_fields = apply_filters( 'show_password_fields', true, $profile_user ); 692 ?> 693 <?php if ( $show_password_fields ) : ?> 694 </table> 695 696 <h2><?php _e( 'Account Management' ); ?></h2> 697 698 <table class="form-table" role="presentation"> 699 <tr id="password" class="user-pass1-wrap"> 700 <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th> 701 <td> 702 <input type="hidden" value=" " /><!-- #24364 workaround --> 703 <button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="false"><?php _e( 'Set New Password' ); ?></button> 704 <div class="wp-pwd hide-if-js"> 705 <div class="password-input-wrapper"> 706 <input type="password" name="pass1" id="pass1" class="regular-text ltr" value="" autocomplete="new-password" spellcheck="false" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" /> 707 <div style="display:none" id="pass-strength-result" aria-live="polite"></div> 708 </div> 709 <button type="button" class="button wp-hide-pw user-new-password-toggle hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> 710 <span class="dashicons dashicons-hidden" aria-hidden="true"></span> 711 <span class="text"><?php _e( 'Hide' ); ?></span> 712 </button> 713 <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>"> 714 <span class="dashicons dashicons-no" aria-hidden="true"></span> 715 <span class="text"><?php _e( 'Cancel' ); ?></span> 716 </button> 717 </div> 718 </td> 719 </tr> 720 <tr class="user-pass2-wrap hide-if-js"> 721 <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th> 722 <td> 723 <input type="password" name="pass2" id="pass2" class="regular-text" value="" autocomplete="new-password" spellcheck="false" aria-describedby="pass2-desc" /> 724 <?php if ( IS_PROFILE_PAGE ) : ?> 725 <p class="description" id="pass2-desc"><?php _e( 'Type your new password again.' ); ?></p> 726 <?php else : ?> 727 <p class="description" id="pass2-desc"><?php _e( 'Type the new password again.' ); ?></p> 728 <?php endif; ?> 729 </td> 730 </tr> 731 <tr class="pw-weak"> 732 <th><?php _e( 'Confirm Password' ); ?></th> 733 <td> 734 <label> 735 <input type="checkbox" name="pw_weak" class="pw-checkbox" /> 736 <span id="pw-weak-text-label"><?php _e( 'Confirm use of weak password' ); ?></span> 737 </label> 738 </td> 739 </tr> 740 <?php endif; // End Show Password Fields. ?> 741 742 <?php // Allow admins to send reset password link. ?> 743 <?php if ( ! IS_PROFILE_PAGE && true === wp_is_password_reset_allowed_for_user( $profile_user ) ) : ?> 744 <tr class="user-generate-reset-link-wrap hide-if-no-js"> 745 <th><?php _e( 'Password Reset' ); ?></th> 746 <td> 747 <div class="generate-reset-link"> 748 <button type="button" class="button button-secondary" id="generate-reset-link"> 749 <?php _e( 'Send Reset Link' ); ?> 750 </button> 751 </div> 752 <p class="description"> 753 <?php 754 printf( 755 /* translators: %s: User's display name. */ 756 __( 'Send %s a link to reset their password. This will not change their password, nor will it force a change.' ), 757 esc_html( $profile_user->display_name ) 758 ); 759 ?> 760 </p> 761 </td> 762 </tr> 763 <?php endif; ?> 764 765 <?php if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?> 766 <tr class="user-sessions-wrap hide-if-no-js"> 767 <th><?php _e( 'Sessions' ); ?></th> 768 <td aria-live="assertive"> 769 <div class="destroy-sessions"><button type="button" disabled class="button"><?php _e( 'Log Out Everywhere Else' ); ?></button></div> 770 <p class="description"> 771 <?php _e( 'You are only logged in at this location.' ); ?> 772 </p> 773 </td> 774 </tr> 775 <?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?> 776 <tr class="user-sessions-wrap hide-if-no-js"> 777 <th><?php _e( 'Sessions' ); ?></th> 778 <td aria-live="assertive"> 779 <div class="destroy-sessions"><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere Else' ); ?></button></div> 780 <p class="description"> 781 <?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.' ); ?> 782 </p> 783 </td> 784 </tr> 785 <?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?> 786 <tr class="user-sessions-wrap hide-if-no-js"> 787 <th><?php _e( 'Sessions' ); ?></th> 788 <td> 789 <p><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere' ); ?></button></p> 790 <p class="description"> 791 <?php 792 /* translators: %s: User's display name. */ 793 printf( __( 'Log %s out of all locations.' ), $profile_user->display_name ); 794 ?> 795 </p> 796 </td> 797 </tr> 798 <?php endif; ?> 799 </table> 800 801 <?php if ( wp_is_application_passwords_available_for_user( $user_id ) || ! wp_is_application_passwords_supported() ) : ?> 802 <div class="application-passwords hide-if-no-js" id="application-passwords-section"> 803 <h2><?php _e( 'Application Passwords' ); ?></h2> 804 <p><?php _e( 'Application passwords allow authentication via non-interactive systems, such as XML-RPC or the REST API, without providing your actual password. Application passwords can be easily revoked. They cannot be used for traditional logins to your website.' ); ?></p> 805 <?php if ( wp_is_application_passwords_available_for_user( $user_id ) ) : ?> 806 <?php 807 if ( is_multisite() ) : 808 $blogs = get_blogs_of_user( $user_id, true ); 809 $blogs_count = count( $blogs ); 810 811 if ( $blogs_count > 1 ) : 812 ?> 813 <p> 814 <?php 815 /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */ 816 $message = _n( 817 'Application passwords grant access to <a href="%1$s">the %2$s site in this installation that you have permissions on</a>.', 818 'Application passwords grant access to <a href="%1$s">all %2$s sites in this installation that you have permissions on</a>.', 819 $blogs_count 820 ); 821 822 if ( is_super_admin( $user_id ) ) { 823 /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */ 824 $message = _n( 825 'Application passwords grant access to <a href="%1$s">the %2$s site on the network as you have Super Admin rights</a>.', 826 'Application passwords grant access to <a href="%1$s">all %2$s sites on the network as you have Super Admin rights</a>.', 827 $blogs_count 828 ); 829 } 830 831 printf( 832 $message, 833 admin_url( 'my-sites.php' ), 834 number_format_i18n( $blogs_count ) 835 ); 836 ?> 837 </p> 838 <?php 839 endif; 840 endif; 841 ?> 842 843 <?php if ( ! wp_is_site_protected_by_basic_auth( 'front' ) ) : ?> 844 <div class="create-application-password form-wrap"> 845 <div class="form-field"> 846 <label for="new_application_password_name"><?php _e( 'New Application Password Name' ); ?></label> 847 <input type="text" size="30" id="new_application_password_name" name="new_application_password_name" class="input ltr" aria-required="true" aria-describedby="new_application_password_name_desc" spellcheck="false" /> 848 <p class="description" id="new_application_password_name_desc"><?php _e( 'Required to create an Application Password, but not to update the user.' ); ?></p> 849 </div> 850 851 <?php 852 /** 853 * Fires in the create Application Passwords form. 854 * 855 * @since 5.6.0 856 * 857 * @param WP_User $profile_user The current WP_User object. 858 */ 859 do_action( 'wp_create_application_password_form', $profile_user ); 860 ?> 861 862 <button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add Application Password' ); ?></button> 863 </div> 864 <?php 865 else : 866 wp_admin_notice( 867 __( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ), 868 array( 869 'type' => 'error', 870 'additional_classes' => array( 'inline' ), 871 ) 872 ); 873 endif; 874 ?> 875 876 <div class="application-passwords-list-table-wrapper"> 877 <?php 878 $application_passwords_list_table = _get_list_table( 'WP_Application_Passwords_List_Table', array( 'screen' => 'application-passwords-user' ) ); 879 $application_passwords_list_table->prepare_items(); 880 $application_passwords_list_table->display(); 881 ?> 882 </div> 883 <?php elseif ( ! wp_is_application_passwords_supported() ) : ?> 884 <p><?php _e( 'The application password feature requires HTTPS, which is not enabled on this site.' ); ?></p> 885 <p> 886 <?php 887 printf( 888 /* translators: %s: Documentation URL. */ 889 __( 'If this is a development website, you can <a href="%s">set the environment type accordingly</a> to enable application passwords.' ), 890 __( 'https://developer.wordpress.org/apis/wp-config-php/#wp-environment-type' ) 891 ); 892 ?> 893 </p> 894 <?php endif; ?> 895 </div> 896 <?php endif; // End Application Passwords. ?> 897 898 <?php 899 if ( IS_PROFILE_PAGE ) { 900 /** 901 * Fires after the 'Application Passwords' section is loaded on the 'Profile' editing screen. 902 * 903 * The action only fires if the current user is editing their own profile. 904 * 905 * @since 2.0.0 906 * 907 * @param WP_User $profile_user The current WP_User object. 908 */ 909 do_action( 'show_user_profile', $profile_user ); 910 } else { 911 /** 912 * Fires after the 'Application Passwords' section is loaded on 'Edit User' screen. 913 * 914 * The action only fires if the current user is editing another user's profile. 915 * 916 * @since 2.0.0 917 * 918 * @param WP_User $profile_user The current WP_User object. 919 */ 920 do_action( 'edit_user_profile', $profile_user ); 921 } 922 ?> 923 924 <?php 925 /** 926 * Filters whether to display additional capabilities for the user. 927 * 928 * The 'Additional Capabilities' section will only be enabled if 929 * the number of the user's capabilities exceeds their number of 930 * roles. 931 * 932 * @since 2.8.0 933 * 934 * @param bool $enable Whether to display the capabilities. Default true. 935 * @param WP_User $profile_user The current WP_User object. 936 */ 937 $display_additional_caps = apply_filters( 'additional_capabilities_display', true, $profile_user ); 938 ?> 939 940 <?php if ( count( $profile_user->caps ) > count( $profile_user->roles ) && ( true === $display_additional_caps ) ) : ?> 941 <h2><?php _e( 'Additional Capabilities' ); ?></h2> 942 943 <table class="form-table" role="presentation"> 944 <tr class="user-capabilities-wrap"> 945 <th scope="row"><?php _e( 'Capabilities' ); ?></th> 946 <td> 947 <?php 948 $output = ''; 949 foreach ( $profile_user->caps as $cap => $value ) { 950 if ( ! $wp_roles->is_role( $cap ) ) { 951 if ( '' !== $output ) { 952 $output .= ', '; 953 } 954 955 if ( $value ) { 956 $output .= $cap; 957 } else { 958 /* translators: %s: Capability name. */ 959 $output .= sprintf( __( 'Denied: %s' ), $cap ); 960 } 961 } 962 } 963 echo $output; 964 ?> 965 </td> 966 </tr> 967 </table> 968 <?php endif; // End Display Additional Capabilities. ?> 969 970 <input type="hidden" name="action" value="update" /> 971 <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user_id ); ?>" /> 972 973 <?php submit_button( IS_PROFILE_PAGE ? __( 'Update Profile' ) : __( 'Update User' ) ); ?> 974 975 </form> 976 </div> 977 <?php 978 break; 979 } 980 ?> 981 <script> 982 if (window.location.hash == '#password') { 983 document.getElementById('pass1').focus(); 984 } 985 </script> 986 987 <script> 988 jQuery( function( $ ) { 989 var languageSelect = $( '#locale' ); 990 $( 'form' ).on( 'submit', function() { 991 /* 992 * Don't show a spinner for English and installed languages, 993 * as there is nothing to download. 994 */ 995 if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) { 996 $( '#submit', this ).after( '<span class="spinner language-install-spinner is-active" />' ); 997 } 998 }); 999 } ); 1000 </script> 1001 1002 <?php if ( isset( $application_passwords_list_table ) ) : ?> 1003 <script type="text/html" id="tmpl-new-application-password"> 1004 <div class="notice notice-success is-dismissible new-application-password-notice" role="alert"> 1005 <p class="application-password-display"> 1006 <label for="new-application-password-value"> 1007 <?php 1008 printf( 1009 /* translators: %s: Application name. */ 1010 __( 'Your new password for %s is:' ), 1011 '<strong>{{ data.name }}</strong>' 1012 ); 1013 ?> 1014 </label> 1015 <input id="new-application-password-value" type="text" class="code" readonly="readonly" value="{{ data.password }}" /> 1016 <button type="button" class="button copy-button" data-clipboard-text="{{ data.password }}"><?php _e( 'Copy' ); ?></button> 1017 <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span> 1018 </p> 1019 <p><?php _e( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ); ?></p> 1020 <button type="button" class="notice-dismiss"> 1021 <span class="screen-reader-text"> 1022 <?php 1023 /* translators: Hidden accessibility text. */ 1024 _e( 'Dismiss this notice.' ); 1025 ?> 1026 </span> 1027 </button> 1028 </div> 1029 </script> 1030 1031 <script type="text/html" id="tmpl-application-password-row"> 1032 <?php $application_passwords_list_table->print_js_template_row(); ?> 1033 </script> 1034 <?php endif; ?> 1035 <?php 1036 require_once ABSPATH . 'wp-admin/admin-footer.php';
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sat Jul 4 08:20:12 2026 | Cross-referenced by PHPXref |