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