[ 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 380 $languages = get_available_languages(); 381 $can_install_translations = current_user_can( 'install_languages' ) && wp_can_install_language_pack(); 382 ?> 383 <?php if ( $languages || $can_install_translations ) : ?> 384 <tr class="user-language-wrap"> 385 <th scope="row"> 386 <?php /* translators: The user language selection field label. */ ?> 387 <label for="locale"><?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label> 388 </th> 389 <td> 390 <?php 391 $user_locale = $profile_user->locale; 392 393 if ( 'en_US' === $user_locale ) { 394 $user_locale = ''; 395 } elseif ( '' === $user_locale || ! in_array( $user_locale, $languages, true ) ) { 396 $user_locale = 'site-default'; 397 } 398 399 wp_dropdown_languages( 400 array( 401 'name' => 'locale', 402 'id' => 'locale', 403 'selected' => $user_locale, 404 'languages' => $languages, 405 'show_available_translations' => $can_install_translations, 406 'show_option_site_default' => true, 407 ) 408 ); 409 ?> 410 </td> 411 </tr> 412 <?php endif; ?> 413 414 <?php 415 /** 416 * Fires at the end of the 'Personal Options' settings table on the user editing screen. 417 * 418 * @since 2.7.0 419 * 420 * @param WP_User $profile_user The current WP_User object. 421 */ 422 do_action( 'personal_options', $profile_user ); 423 ?> 424 425 </table> 426 <?php 427 if ( IS_PROFILE_PAGE ) { 428 /** 429 * Fires after the 'Personal Options' settings table on the 'Profile' editing screen. 430 * 431 * The action only fires if the current user is editing their own profile. 432 * 433 * @since 2.0.0 434 * 435 * @param WP_User $profile_user The current WP_User object. 436 */ 437 do_action( 'profile_personal_options', $profile_user ); 438 } 439 ?> 440 441 <h2><?php _e( 'Name' ); ?></h2> 442 443 <table class="form-table" role="presentation"> 444 <tr class="user-user-login-wrap"> 445 <th><label for="user_login"><?php _e( 'Username' ); ?></label></th> 446 <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr( $profile_user->user_login ); ?>" readonly="readonly" class="regular-text" /> <span class="description"><?php _e( 'Usernames cannot be changed.' ); ?></span></td> 447 </tr> 448 449 <?php if ( ! IS_PROFILE_PAGE && ! is_network_admin() && current_user_can( 'promote_user', $profile_user->ID ) ) : ?> 450 <tr class="user-role-wrap"> 451 <th><label for="role"><?php _e( 'Role' ); ?></label></th> 452 <td> 453 <select name="role" id="role"> 454 <?php 455 // Compare user role against currently editable roles. 456 $user_roles = array_intersect( array_values( $profile_user->roles ), array_keys( get_editable_roles() ) ); 457 $user_role = reset( $user_roles ); 458 459 // Print the full list of roles with the primary one selected. 460 wp_dropdown_roles( $user_role ); 461 462 // Print the 'no role' option. Make it selected if the user has no role yet. 463 if ( $user_role ) { 464 echo '<option value="">' . __( '— No role for this site —' ) . '</option>'; 465 } else { 466 echo '<option value="" selected="selected">' . __( '— No role for this site —' ) . '</option>'; 467 } 468 ?> 469 </select> 470 </td> 471 </tr> 472 <?php endif; // End if ! IS_PROFILE_PAGE. ?> 473 474 <?php if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && ! isset( $super_admins ) ) : ?> 475 <tr class="user-super-admin-wrap"> 476 <th><?php _e( 'Super Admin' ); ?></th> 477 <td> 478 <?php if ( 0 !== strcasecmp( $profile_user->user_email, get_site_option( 'admin_email' ) ) || ! is_super_admin( $profile_user->ID ) ) : ?> 479 <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> 480 <?php else : ?> 481 <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p> 482 <?php endif; ?> 483 </td> 484 </tr> 485 <?php endif; ?> 486 487 <tr class="user-first-name-wrap"> 488 <th><label for="first_name"><?php _e( 'First Name' ); ?></label></th> 489 <td> 490 <?php if ( IS_PROFILE_PAGE ) : ?> 491 <input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profile_user->first_name ); ?>" autocomplete="given-name" class="regular-text" /> 492 <?php else : ?> 493 <input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profile_user->first_name ); ?>" class="regular-text" /> 494 <?php endif; ?> 495 </td> 496 </tr> 497 498 <tr class="user-last-name-wrap"> 499 <th><label for="last_name"><?php _e( 'Last Name' ); ?></label></th> 500 <td> 501 <?php if ( IS_PROFILE_PAGE ) : ?> 502 <input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profile_user->last_name ); ?>" autocomplete="family-name" class="regular-text" /> 503 <?php else : ?> 504 <input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profile_user->last_name ); ?>" class="regular-text" /> 505 <?php endif; ?> 506 </td> 507 </tr> 508 509 <tr class="user-nickname-wrap"> 510 <th><label for="nickname"><?php _e( 'Nickname' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> 511 <td> 512 <?php if ( IS_PROFILE_PAGE ) : ?> 513 <input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profile_user->nickname ); ?>" autocomplete="nickname" class="regular-text" /> 514 <?php else : ?> 515 <input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profile_user->nickname ); ?>" class="regular-text" /> 516 <?php endif; ?> 517 </td> 518 </tr> 519 520 <tr class="user-display-name-wrap"> 521 <th> 522 <label for="display_name"><?php _e( 'Display name publicly as' ); ?></label> 523 </th> 524 <td> 525 <select name="display_name" id="display_name"> 526 <?php 527 $public_display = array(); 528 $public_display['display_nickname'] = $profile_user->nickname; 529 $public_display['display_username'] = $profile_user->user_login; 530 531 if ( ! empty( $profile_user->first_name ) ) { 532 $public_display['display_firstname'] = $profile_user->first_name; 533 } 534 535 if ( ! empty( $profile_user->last_name ) ) { 536 $public_display['display_lastname'] = $profile_user->last_name; 537 } 538 539 if ( ! empty( $profile_user->first_name ) && ! empty( $profile_user->last_name ) ) { 540 $public_display['display_firstlast'] = $profile_user->first_name . ' ' . $profile_user->last_name; 541 $public_display['display_lastfirst'] = $profile_user->last_name . ' ' . $profile_user->first_name; 542 } 543 544 if ( ! in_array( $profile_user->display_name, $public_display, true ) ) { // Only add this if it isn't duplicated elsewhere. 545 $public_display = array( 'display_displayname' => $profile_user->display_name ) + $public_display; 546 } 547 548 $public_display = array_map( 'trim', $public_display ); 549 $public_display = array_unique( $public_display ); 550 551 ?> 552 <?php foreach ( $public_display as $id => $item ) : ?> 553 <option <?php selected( $profile_user->display_name, $item ); ?>><?php echo $item; ?></option> 554 <?php endforeach; ?> 555 </select> 556 </td> 557 </tr> 558 </table> 559 560 <h2><?php _e( 'Contact Info' ); ?></h2> 561 562 <table class="form-table" role="presentation"> 563 <tr class="user-email-wrap"> 564 <th><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> 565 <td> 566 <?php if ( $profile_user->ID === $current_user->ID ) : ?> 567 <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" /> 568 <p class="description" id="email-description"> 569 <?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>' ); ?> 570 </p> 571 <?php else : ?> 572 <input type="email" name="email" id="email" value="<?php echo esc_attr( $profile_user->user_email ); ?>" class="regular-text ltr" /> 573 <?php endif; ?> 574 575 <?php 576 $new_email = get_user_meta( $current_user->ID, '_new_email', true ); 577 if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) : 578 579 $pending_change_message = sprintf( 580 /* translators: %s: New email. */ 581 __( 'There is a pending change of your email to %s.' ), 582 '<code>' . esc_html( $new_email['newemail'] ) . '</code>' 583 ); 584 $pending_change_message .= sprintf( 585 ' <a href="%1$s">%2$s</a>', 586 esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ), 587 __( 'Cancel' ) 588 ); 589 wp_admin_notice( 590 $pending_change_message, 591 array( 592 'additional_classes' => array( 'updated', 'inline' ), 593 ) 594 ); 595 endif; 596 ?> 597 </td> 598 </tr> 599 600 <tr class="user-url-wrap"> 601 <th><label for="url"><?php _e( 'Website' ); ?></label></th> 602 <td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profile_user->user_url ); ?>" class="regular-text code" /></td> 603 </tr> 604 605 <?php foreach ( wp_get_user_contact_methods( $profile_user ) as $name => $desc ) : ?> 606 <tr class="user-<?php echo $name; ?>-wrap"> 607 <th> 608 <label for="<?php echo $name; ?>"> 609 <?php 610 /** 611 * Filters a user contactmethod label. 612 * 613 * The dynamic portion of the hook name, `$name`, refers to 614 * each of the keys in the contact methods array. 615 * 616 * @since 2.9.0 617 * 618 * @param string $desc The translatable label for the contact method. 619 */ 620 echo apply_filters( "user_{$name}_label", $desc ); 621 ?> 622 </label> 623 </th> 624 <td> 625 <input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profile_user->$name ); ?>" class="regular-text" /> 626 </td> 627 </tr> 628 <?php endforeach; ?> 629 </table> 630 631 <h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2> 632 633 <table class="form-table" role="presentation"> 634 <tr class="user-description-wrap"> 635 <th><label for="description"><?php _e( 'Biographical Info' ); ?></label></th> 636 <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profile_user->description; // textarea_escaped ?></textarea> 637 <p class="description"><?php _e( 'Share a little biographical information to fill out your profile. This may be shown publicly.' ); ?></p></td> 638 </tr> 639 640 <?php if ( get_option( 'show_avatars' ) ) : ?> 641 <tr class="user-profile-picture"> 642 <th><?php _e( 'Profile Picture' ); ?></th> 643 <td> 644 <?php echo get_avatar( $user_id ); ?> 645 <p class="description"> 646 <?php 647 if ( IS_PROFILE_PAGE ) { 648 $description = sprintf( 649 /* translators: %s: Gravatar URL. */ 650 __( '<a href="%s">You can change your profile picture on Gravatar</a>.' ), 651 /* translators: The localized Gravatar URL. */ 652 __( 'https://gravatar.com/' ) 653 ); 654 } else { 655 $description = ''; 656 } 657 658 /** 659 * Filters the user profile picture description displayed under the Gravatar. 660 * 661 * @since 4.4.0 662 * @since 4.7.0 Added the `$profile_user` parameter. 663 * 664 * @param string $description The description that will be printed. 665 * @param WP_User $profile_user The current WP_User object. 666 */ 667 echo apply_filters( 'user_profile_picture_description', $description, $profile_user ); 668 ?> 669 </p> 670 </td> 671 </tr> 672 <?php endif; ?> 673 <?php 674 /** 675 * Filters the display of the password fields. 676 * 677 * @since 1.5.1 678 * @since 2.8.0 Added the `$profile_user` parameter. 679 * @since 4.4.0 Now evaluated only in user-edit.php. 680 * 681 * @param bool $show Whether to show the password fields. Default true. 682 * @param WP_User $profile_user User object for the current user to edit. 683 */ 684 $show_password_fields = apply_filters( 'show_password_fields', true, $profile_user ); 685 ?> 686 <?php if ( $show_password_fields ) : ?> 687 </table> 688 689 <h2><?php _e( 'Account Management' ); ?></h2> 690 691 <table class="form-table" role="presentation"> 692 <tr id="password" class="user-pass1-wrap"> 693 <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th> 694 <td> 695 <input type="hidden" value=" " /><!-- #24364 workaround --> 696 <button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="false"><?php _e( 'Set New Password' ); ?></button> 697 <div class="wp-pwd hide-if-js"> 698 <div class="password-input-wrapper"> 699 <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="new-password" spellcheck="false" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" /> 700 <div style="display:none" id="pass-strength-result" aria-live="polite"></div> 701 </div> 702 <button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> 703 <span class="dashicons dashicons-hidden" aria-hidden="true"></span> 704 <span class="text"><?php _e( 'Hide' ); ?></span> 705 </button> 706 <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>"> 707 <span class="dashicons dashicons-no" aria-hidden="true"></span> 708 <span class="text"><?php _e( 'Cancel' ); ?></span> 709 </button> 710 </div> 711 </td> 712 </tr> 713 <tr class="user-pass2-wrap hide-if-js"> 714 <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th> 715 <td> 716 <input type="password" name="pass2" id="pass2" class="regular-text" value="" autocomplete="new-password" spellcheck="false" aria-describedby="pass2-desc" /> 717 <?php if ( IS_PROFILE_PAGE ) : ?> 718 <p class="description" id="pass2-desc"><?php _e( 'Type your new password again.' ); ?></p> 719 <?php else : ?> 720 <p class="description" id="pass2-desc"><?php _e( 'Type the new password again.' ); ?></p> 721 <?php endif; ?> 722 </td> 723 </tr> 724 <tr class="pw-weak"> 725 <th><?php _e( 'Confirm Password' ); ?></th> 726 <td> 727 <label> 728 <input type="checkbox" name="pw_weak" class="pw-checkbox" /> 729 <span id="pw-weak-text-label"><?php _e( 'Confirm use of weak password' ); ?></span> 730 </label> 731 </td> 732 </tr> 733 <?php endif; // End Show Password Fields. ?> 734 735 <?php // Allow admins to send reset password link. ?> 736 <?php if ( ! IS_PROFILE_PAGE && true === wp_is_password_reset_allowed_for_user( $profile_user ) ) : ?> 737 <tr class="user-generate-reset-link-wrap hide-if-no-js"> 738 <th><?php _e( 'Password Reset' ); ?></th> 739 <td> 740 <div class="generate-reset-link"> 741 <button type="button" class="button button-secondary" id="generate-reset-link"> 742 <?php _e( 'Send Reset Link' ); ?> 743 </button> 744 </div> 745 <p class="description"> 746 <?php 747 printf( 748 /* translators: %s: User's display name. */ 749 __( 'Send %s a link to reset their password. This will not change their password, nor will it force a change.' ), 750 esc_html( $profile_user->display_name ) 751 ); 752 ?> 753 </p> 754 </td> 755 </tr> 756 <?php endif; ?> 757 758 <?php if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?> 759 <tr class="user-sessions-wrap hide-if-no-js"> 760 <th><?php _e( 'Sessions' ); ?></th> 761 <td aria-live="assertive"> 762 <div class="destroy-sessions"><button type="button" disabled class="button"><?php _e( 'Log Out Everywhere Else' ); ?></button></div> 763 <p class="description"> 764 <?php _e( 'You are only logged in at this location.' ); ?> 765 </p> 766 </td> 767 </tr> 768 <?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?> 769 <tr class="user-sessions-wrap hide-if-no-js"> 770 <th><?php _e( 'Sessions' ); ?></th> 771 <td aria-live="assertive"> 772 <div class="destroy-sessions"><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere Else' ); ?></button></div> 773 <p class="description"> 774 <?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.' ); ?> 775 </p> 776 </td> 777 </tr> 778 <?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?> 779 <tr class="user-sessions-wrap hide-if-no-js"> 780 <th><?php _e( 'Sessions' ); ?></th> 781 <td> 782 <p><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere' ); ?></button></p> 783 <p class="description"> 784 <?php 785 /* translators: %s: User's display name. */ 786 printf( __( 'Log %s out of all locations.' ), $profile_user->display_name ); 787 ?> 788 </p> 789 </td> 790 </tr> 791 <?php endif; ?> 792 </table> 793 794 <?php if ( wp_is_application_passwords_available_for_user( $user_id ) || ! wp_is_application_passwords_supported() ) : ?> 795 <div class="application-passwords hide-if-no-js" id="application-passwords-section"> 796 <h2><?php _e( 'Application Passwords' ); ?></h2> 797 <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> 798 <?php if ( wp_is_application_passwords_available_for_user( $user_id ) ) : ?> 799 <?php 800 if ( is_multisite() ) : 801 $blogs = get_blogs_of_user( $user_id, true ); 802 $blogs_count = count( $blogs ); 803 804 if ( $blogs_count > 1 ) : 805 ?> 806 <p> 807 <?php 808 /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */ 809 $message = _n( 810 'Application passwords grant access to <a href="%1$s">the %2$s site in this installation that you have permissions on</a>.', 811 'Application passwords grant access to <a href="%1$s">all %2$s sites in this installation that you have permissions on</a>.', 812 $blogs_count 813 ); 814 815 if ( is_super_admin( $user_id ) ) { 816 /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */ 817 $message = _n( 818 'Application passwords grant access to <a href="%1$s">the %2$s site on the network as you have Super Admin rights</a>.', 819 'Application passwords grant access to <a href="%1$s">all %2$s sites on the network as you have Super Admin rights</a>.', 820 $blogs_count 821 ); 822 } 823 824 printf( 825 $message, 826 admin_url( 'my-sites.php' ), 827 number_format_i18n( $blogs_count ) 828 ); 829 ?> 830 </p> 831 <?php 832 endif; 833 endif; 834 ?> 835 836 <?php if ( ! wp_is_site_protected_by_basic_auth( 'front' ) ) : ?> 837 <div class="create-application-password form-wrap"> 838 <div class="form-field"> 839 <label for="new_application_password_name"><?php _e( 'New Application Password Name' ); ?></label> 840 <input type="text" size="30" id="new_application_password_name" name="new_application_password_name" class="input" aria-required="true" aria-describedby="new_application_password_name_desc" spellcheck="false" /> 841 <p class="description" id="new_application_password_name_desc"><?php _e( 'Required to create an Application Password, but not to update the user.' ); ?></p> 842 </div> 843 844 <?php 845 /** 846 * Fires in the create Application Passwords form. 847 * 848 * @since 5.6.0 849 * 850 * @param WP_User $profile_user The current WP_User object. 851 */ 852 do_action( 'wp_create_application_password_form', $profile_user ); 853 ?> 854 855 <button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add Application Password' ); ?></button> 856 </div> 857 <?php 858 else : 859 wp_admin_notice( 860 __( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ), 861 array( 862 'type' => 'error', 863 'additional_classes' => array( 'inline' ), 864 ) 865 ); 866 endif; 867 ?> 868 869 <div class="application-passwords-list-table-wrapper"> 870 <?php 871 $application_passwords_list_table = _get_list_table( 'WP_Application_Passwords_List_Table', array( 'screen' => 'application-passwords-user' ) ); 872 $application_passwords_list_table->prepare_items(); 873 $application_passwords_list_table->display(); 874 ?> 875 </div> 876 <?php elseif ( ! wp_is_application_passwords_supported() ) : ?> 877 <p><?php _e( 'The application password feature requires HTTPS, which is not enabled on this site.' ); ?></p> 878 <p> 879 <?php 880 printf( 881 /* translators: %s: Documentation URL. */ 882 __( 'If this is a development website, you can <a href="%s">set the environment type accordingly</a> to enable application passwords.' ), 883 __( 'https://developer.wordpress.org/apis/wp-config-php/#wp-environment-type' ) 884 ); 885 ?> 886 </p> 887 <?php endif; ?> 888 </div> 889 <?php endif; // End Application Passwords. ?> 890 891 <?php 892 if ( IS_PROFILE_PAGE ) { 893 /** 894 * Fires after the 'About Yourself' settings table on the 'Profile' editing screen. 895 * 896 * The action only fires if the current user is editing their own profile. 897 * 898 * @since 2.0.0 899 * 900 * @param WP_User $profile_user The current WP_User object. 901 */ 902 do_action( 'show_user_profile', $profile_user ); 903 } else { 904 /** 905 * Fires after the 'About the User' settings table on the 'Edit User' screen. 906 * 907 * @since 2.0.0 908 * 909 * @param WP_User $profile_user The current WP_User object. 910 */ 911 do_action( 'edit_user_profile', $profile_user ); 912 } 913 ?> 914 915 <?php 916 /** 917 * Filters whether to display additional capabilities for the user. 918 * 919 * The 'Additional Capabilities' section will only be enabled if 920 * the number of the user's capabilities exceeds their number of 921 * roles. 922 * 923 * @since 2.8.0 924 * 925 * @param bool $enable Whether to display the capabilities. Default true. 926 * @param WP_User $profile_user The current WP_User object. 927 */ 928 $display_additional_caps = apply_filters( 'additional_capabilities_display', true, $profile_user ); 929 ?> 930 931 <?php if ( count( $profile_user->caps ) > count( $profile_user->roles ) && ( true === $display_additional_caps ) ) : ?> 932 <h2><?php _e( 'Additional Capabilities' ); ?></h2> 933 934 <table class="form-table" role="presentation"> 935 <tr class="user-capabilities-wrap"> 936 <th scope="row"><?php _e( 'Capabilities' ); ?></th> 937 <td> 938 <?php 939 $output = ''; 940 foreach ( $profile_user->caps as $cap => $value ) { 941 if ( ! $wp_roles->is_role( $cap ) ) { 942 if ( '' !== $output ) { 943 $output .= ', '; 944 } 945 946 if ( $value ) { 947 $output .= $cap; 948 } else { 949 /* translators: %s: Capability name. */ 950 $output .= sprintf( __( 'Denied: %s' ), $cap ); 951 } 952 } 953 } 954 echo $output; 955 ?> 956 </td> 957 </tr> 958 </table> 959 <?php endif; // End Display Additional Capabilities. ?> 960 961 <input type="hidden" name="action" value="update" /> 962 <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user_id ); ?>" /> 963 964 <?php submit_button( IS_PROFILE_PAGE ? __( 'Update Profile' ) : __( 'Update User' ) ); ?> 965 966 </form> 967 </div> 968 <?php 969 break; 970 } 971 ?> 972 <script type="text/javascript"> 973 if (window.location.hash == '#password') { 974 document.getElementById('pass1').focus(); 975 } 976 </script> 977 978 <script type="text/javascript"> 979 jQuery( function( $ ) { 980 var languageSelect = $( '#locale' ); 981 $( 'form' ).on( 'submit', function() { 982 /* 983 * Don't show a spinner for English and installed languages, 984 * as there is nothing to download. 985 */ 986 if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) { 987 $( '#submit', this ).after( '<span class="spinner language-install-spinner is-active" />' ); 988 } 989 }); 990 } ); 991 </script> 992 993 <?php if ( isset( $application_passwords_list_table ) ) : ?> 994 <script type="text/html" id="tmpl-new-application-password"> 995 <div class="notice notice-success is-dismissible new-application-password-notice" role="alert"> 996 <p class="application-password-display"> 997 <label for="new-application-password-value"> 998 <?php 999 printf( 1000 /* translators: %s: Application name. */ 1001 __( 'Your new password for %s is:' ), 1002 '<strong>{{ data.name }}</strong>' 1003 ); 1004 ?> 1005 </label> 1006 <input id="new-application-password-value" type="text" class="code" readonly="readonly" value="{{ data.password }}" /> 1007 <button type="button" class="button copy-button" data-clipboard-text="{{ data.password }}"><?php _e( 'Copy' ); ?></button> 1008 <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span> 1009 </p> 1010 <p><?php _e( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ); ?></p> 1011 <button type="button" class="notice-dismiss"> 1012 <span class="screen-reader-text"> 1013 <?php 1014 /* translators: Hidden accessibility text. */ 1015 _e( 'Dismiss this notice.' ); 1016 ?> 1017 </span> 1018 </button> 1019 </div> 1020 </script> 1021 1022 <script type="text/html" id="tmpl-application-password-row"> 1023 <?php $application_passwords_list_table->print_js_template_row(); ?> 1024 </script> 1025 <?php endif; ?> 1026 <?php 1027 require_once ABSPATH . 'wp-admin/admin-footer.php';
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sun Jun 22 08:20:01 2025 | Cross-referenced by PHPXref |