[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/ -> user-edit.php (source)

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


Generated : Thu Nov 6 08:20:07 2025 Cross-referenced by PHPXref