[ Index ]

PHP Cross Reference of WordPress

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


Generated: Sun Sep 19 01:00:04 2021 Cross-referenced by PHPXref 0.7.1