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


Generated: Sun Apr 5 01:00:03 2020 Cross-referenced by PHPXref 0.7.1