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