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