[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

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( dirname( __FILE__ ) . '/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          include ( 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
 314  endif; // $_wp_admin_css_colors
 315          if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) :
 316              ?>
 317      <tr class="user-comment-shortcuts-wrap">
 318          <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
 319          <td>
 320              <label for="comment_shortcuts">
 321                  <input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php checked( 'true', $profileuser->comment_shortcuts ); ?> />
 322                  <?php _e( 'Enable keyboard shortcuts for comment moderation.' ); ?>
 323              </label>
 324              <?php _e( '<a href="https://wordpress.org/support/article/keyboard-shortcuts/" target="_blank">More information</a>' ); ?>
 325          </td>
 326      </tr>
 327          <?php endif; ?>
 328  
 329      <tr class="show-admin-bar user-admin-bar-front-wrap">
 330          <th scope="row"><?php _e( 'Toolbar' ); ?></th>
 331          <td>
 332              <label for="admin_bar_front">
 333                  <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
 334                  <?php _e( 'Show Toolbar when viewing site' ); ?>
 335              </label><br />
 336          </td>
 337      </tr>
 338  
 339          <?php
 340          $languages = get_available_languages();
 341          if ( $languages ) :
 342              ?>
 343      <tr class="user-language-wrap">
 344          <th scope="row">
 345              <?php /* translators: The user language selection field label. */ ?>
 346              <label for="locale"><?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label>
 347          </th>
 348          <td>
 349              <?php
 350                  $user_locale = $profileuser->locale;
 351  
 352              if ( 'en_US' === $user_locale ) {
 353                  $user_locale = '';
 354              } elseif ( '' === $user_locale || ! in_array( $user_locale, $languages, true ) ) {
 355                  $user_locale = 'site-default';
 356              }
 357  
 358              wp_dropdown_languages(
 359                  array(
 360                      'name'                        => 'locale',
 361                      'id'                          => 'locale',
 362                      'selected'                    => $user_locale,
 363                      'languages'                   => $languages,
 364                      'show_available_translations' => false,
 365                      'show_option_site_default'    => true,
 366                  )
 367              );
 368              ?>
 369          </td>
 370      </tr>
 371              <?php
 372  endif;
 373          ?>
 374  
 375          <?php
 376          /**
 377           * Fires at the end of the 'Personal Options' settings table on the user editing screen.
 378           *
 379           * @since 2.7.0
 380           *
 381           * @param WP_User $profileuser The current WP_User object.
 382           */
 383          do_action( 'personal_options', $profileuser );
 384          ?>
 385  
 386  </table>
 387          <?php
 388          if ( IS_PROFILE_PAGE ) {
 389              /**
 390               * Fires after the 'Personal Options' settings table on the 'Your Profile' editing screen.
 391               *
 392               * The action only fires if the current user is editing their own profile.
 393               *
 394               * @since 2.0.0
 395               *
 396               * @param WP_User $profileuser The current WP_User object.
 397               */
 398              do_action( 'profile_personal_options', $profileuser );
 399          }
 400          ?>
 401  
 402  <h2><?php _e( 'Name' ); ?></h2>
 403  
 404  <table class="form-table" role="presentation">
 405      <tr class="user-user-login-wrap">
 406          <th><label for="user_login"><?php _e( 'Username' ); ?></label></th>
 407          <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>
 408      </tr>
 409  
 410          <?php if ( ! IS_PROFILE_PAGE && ! is_network_admin() && current_user_can( 'promote_user', $profileuser->ID ) ) : ?>
 411  <tr class="user-role-wrap"><th><label for="role"><?php _e( 'Role' ); ?></label></th>
 412  <td><select name="role" id="role">
 413              <?php
 414              // Compare user role against currently editable roles
 415              $user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) );
 416              $user_role  = reset( $user_roles );
 417  
 418              // print the full list of roles with the primary one selected.
 419              wp_dropdown_roles( $user_role );
 420  
 421              // print the 'no role' option. Make it selected if the user has no role yet.
 422              if ( $user_role ) {
 423                  echo '<option value="">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
 424              } else {
 425                  echo '<option value="" selected="selected">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
 426              }
 427              ?>
 428  </select></td></tr>
 429              <?php
 430  endif; //!IS_PROFILE_PAGE
 431  
 432          if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && ! isset( $super_admins ) ) {
 433              ?>
 434  <tr class="user-super-admin-wrap"><th><?php _e( 'Super Admin' ); ?></th>
 435  <td>
 436              <?php if ( 0 !== strcasecmp( $profileuser->user_email, get_site_option( 'admin_email' ) ) || ! is_super_admin( $profileuser->ID ) ) : ?>
 437  <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>
 438  <?php else : ?>
 439  <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
 440  <?php endif; ?>
 441  </td></tr>
 442          <?php } ?>
 443  
 444  <tr class="user-first-name-wrap">
 445      <th><label for="first_name"><?php _e( 'First Name' ); ?></label></th>
 446      <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profileuser->first_name ); ?>" class="regular-text" /></td>
 447  </tr>
 448  
 449  <tr class="user-last-name-wrap">
 450      <th><label for="last_name"><?php _e( 'Last Name' ); ?></label></th>
 451      <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profileuser->last_name ); ?>" class="regular-text" /></td>
 452  </tr>
 453  
 454  <tr class="user-nickname-wrap">
 455      <th><label for="nickname"><?php _e( 'Nickname' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
 456      <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profileuser->nickname ); ?>" class="regular-text" /></td>
 457  </tr>
 458  
 459  <tr class="user-display-name-wrap">
 460      <th><label for="display_name"><?php _e( 'Display name publicly as' ); ?></label></th>
 461      <td>
 462          <select name="display_name" id="display_name">
 463          <?php
 464              $public_display                     = array();
 465              $public_display['display_nickname'] = $profileuser->nickname;
 466              $public_display['display_username'] = $profileuser->user_login;
 467  
 468          if ( ! empty( $profileuser->first_name ) ) {
 469              $public_display['display_firstname'] = $profileuser->first_name;
 470          }
 471  
 472          if ( ! empty( $profileuser->last_name ) ) {
 473              $public_display['display_lastname'] = $profileuser->last_name;
 474          }
 475  
 476          if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) {
 477              $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
 478              $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
 479          }
 480  
 481          if ( ! in_array( $profileuser->display_name, $public_display ) ) { // Only add this if it isn't duplicated elsewhere
 482              $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
 483          }
 484  
 485              $public_display = array_map( 'trim', $public_display );
 486              $public_display = array_unique( $public_display );
 487  
 488          foreach ( $public_display as $id => $item ) {
 489              ?>
 490          <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>
 491              <?php
 492          }
 493          ?>
 494          </select>
 495          </td>
 496      </tr>
 497      </table>
 498  
 499      <h2><?php _e( 'Contact Info' ); ?></h2>
 500  
 501      <table class="form-table" role="presentation">
 502      <tr class="user-email-wrap">
 503          <th><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
 504          <td><input type="email" name="email" id="email" aria-describedby="email-description" value="<?php echo esc_attr( $profileuser->user_email ); ?>" class="regular-text ltr" />
 505          <?php
 506          if ( $profileuser->ID == $current_user->ID ) :
 507              ?>
 508          <p class="description" id="email-description">
 509              <?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>' ); ?>
 510          </p>
 511              <?php
 512          endif;
 513  
 514          $new_email = get_user_meta( $current_user->ID, '_new_email', true );
 515          if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) :
 516              ?>
 517          <div class="updated inline">
 518          <p>
 519              <?php
 520              printf(
 521                  /* translators: %s: New email. */
 522                  __( 'There is a pending change of your email to %s.' ),
 523                  '<code>' . esc_html( $new_email['newemail'] ) . '</code>'
 524              );
 525              printf(
 526                  ' <a href="%1$s">%2$s</a>',
 527                  esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ),
 528                  __( 'Cancel' )
 529              );
 530              ?>
 531          </p>
 532          </div>
 533          <?php endif; ?>
 534      </td>
 535      </tr>
 536  
 537      <tr class="user-url-wrap">
 538      <th><label for="url"><?php _e( 'Website' ); ?></label></th>
 539      <td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ); ?>" class="regular-text code" /></td>
 540      </tr>
 541  
 542          <?php
 543          foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) {
 544              ?>
 545      <tr class="user-<?php echo $name; ?>-wrap">
 546  <th><label for="<?php echo $name; ?>">
 547              <?php
 548              /**
 549               * Filters a user contactmethod label.
 550               *
 551               * The dynamic portion of the filter hook, `$name`, refers to
 552               * each of the keys in the contactmethods array.
 553               *
 554               * @since 2.9.0
 555               *
 556               * @param string $desc The translatable label for the contactmethod.
 557               */
 558              echo apply_filters( "user_{$name}_label", $desc );
 559              ?>
 560      </label></th>
 561      <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profileuser->$name ); ?>" class="regular-text" /></td>
 562      </tr>
 563              <?php
 564          }
 565          ?>
 566      </table>
 567  
 568      <h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2>
 569  
 570  <table class="form-table" role="presentation">
 571  <tr class="user-description-wrap">
 572      <th><label for="description"><?php _e( 'Biographical Info' ); ?></label></th>
 573      <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea>
 574      <p class="description"><?php _e( 'Share a little biographical information to fill out your profile. This may be shown publicly.' ); ?></p></td>
 575  </tr>
 576  
 577          <?php if ( get_option( 'show_avatars' ) ) : ?>
 578  <tr class="user-profile-picture">
 579      <th><?php _e( 'Profile Picture' ); ?></th>
 580      <td>
 581              <?php echo get_avatar( $user_id ); ?>
 582          <p class="description">
 583              <?php
 584              if ( IS_PROFILE_PAGE ) {
 585                  $description = sprintf(
 586                      /* translators: %s: Gravatar URL. */
 587                      __( '<a href="%s">You can change your profile picture on Gravatar</a>.' ),
 588                      __( 'https://en.gravatar.com/' )
 589                  );
 590              } else {
 591                  $description = '';
 592              }
 593  
 594              /**
 595               * Filters the user profile picture description displayed under the Gravatar.
 596               *
 597               * @since 4.4.0
 598               * @since 4.7.0 Added the `$profileuser` parameter.
 599               *
 600               * @param string  $description The description that will be printed.
 601               * @param WP_User $profileuser The current WP_User object.
 602               */
 603              echo apply_filters( 'user_profile_picture_description', $description, $profileuser );
 604              ?>
 605          </p>
 606      </td>
 607  </tr>
 608  <?php endif; ?>
 609  
 610          <?php
 611          /**
 612           * Filters the display of the password fields.
 613           *
 614           * @since 1.5.1
 615           * @since 2.8.0 Added the `$profileuser` parameter.
 616           * @since 4.4.0 Now evaluated only in user-edit.php.
 617           *
 618           * @param bool    $show        Whether to show the password fields. Default true.
 619           * @param WP_User $profileuser User object for the current user to edit.
 620           */
 621          $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser );
 622          if ( $show_password_fields ) :
 623              ?>
 624      </table>
 625  
 626      <h2><?php _e( 'Account Management' ); ?></h2>
 627  <table class="form-table" role="presentation">
 628  <tr id="password" class="user-pass1-wrap">
 629      <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
 630      <td>
 631          <input class="hidden" value=" " /><!-- #24364 workaround -->
 632          <button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Generate Password' ); ?></button>
 633          <div class="wp-pwd hide-if-js">
 634              <span class="password-input-wrapper">
 635                  <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" />
 636              </span>
 637              <button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
 638                  <span class="dashicons dashicons-hidden" aria-hidden="true"></span>
 639                  <span class="text"><?php _e( 'Hide' ); ?></span>
 640              </button>
 641              <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>">
 642                  <span class="dashicons dashicons-no" aria-hidden="true"></span>
 643                  <span class="text"><?php _e( 'Cancel' ); ?></span>
 644              </button>
 645              <div style="display:none" id="pass-strength-result" aria-live="polite"></div>
 646          </div>
 647      </td>
 648  </tr>
 649  <tr class="user-pass2-wrap hide-if-js">
 650      <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
 651      <td>
 652      <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" />
 653      <p class="description"><?php _e( 'Type your new password again.' ); ?></p>
 654      </td>
 655  </tr>
 656  <tr class="pw-weak">
 657      <th><?php _e( 'Confirm Password' ); ?></th>
 658      <td>
 659          <label>
 660              <input type="checkbox" name="pw_weak" class="pw-checkbox" />
 661              <span id="pw-weak-text-label"><?php _e( 'Confirm use of potentially weak password' ); ?></span>
 662          </label>
 663      </td>
 664  </tr>
 665      <?php endif; ?>
 666  
 667          <?php
 668          if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) :
 669              ?>
 670      <tr class="user-sessions-wrap hide-if-no-js">
 671          <th><?php _e( 'Sessions' ); ?></th>
 672          <td aria-live="assertive">
 673              <div class="destroy-sessions"><button type="button" disabled class="button"><?php _e( 'Log Out Everywhere Else' ); ?></button></div>
 674              <p class="description">
 675                  <?php _e( 'You are only logged in at this location.' ); ?>
 676              </p>
 677          </td>
 678      </tr>
 679  <?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?>
 680      <tr class="user-sessions-wrap hide-if-no-js">
 681          <th><?php _e( 'Sessions' ); ?></th>
 682          <td aria-live="assertive">
 683              <div class="destroy-sessions"><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere Else' ); ?></button></div>
 684              <p class="description">
 685                  <?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.' ); ?>
 686              </p>
 687          </td>
 688      </tr>
 689  <?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?>
 690      <tr class="user-sessions-wrap hide-if-no-js">
 691          <th><?php _e( 'Sessions' ); ?></th>
 692          <td>
 693              <p><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere' ); ?></button></p>
 694              <p class="description">
 695                  <?php
 696                  /* translators: %s: User's display name. */
 697                  printf( __( 'Log %s out of all locations.' ), $profileuser->display_name );
 698                  ?>
 699              </p>
 700          </td>
 701      </tr>
 702  <?php endif; ?>
 703  
 704      </table>
 705  
 706          <?php
 707          if ( IS_PROFILE_PAGE ) {
 708              /**
 709               * Fires after the 'About Yourself' settings table on the 'Your Profile' editing screen.
 710               *
 711               * The action only fires if the current user is editing their own profile.
 712               *
 713               * @since 2.0.0
 714               *
 715               * @param WP_User $profileuser The current WP_User object.
 716               */
 717              do_action( 'show_user_profile', $profileuser );
 718          } else {
 719              /**
 720               * Fires after the 'About the User' settings table on the 'Edit User' screen.
 721               *
 722               * @since 2.0.0
 723               *
 724               * @param WP_User $profileuser The current WP_User object.
 725               */
 726              do_action( 'edit_user_profile', $profileuser );
 727          }
 728          ?>
 729  
 730          <?php
 731          /**
 732           * Filters whether to display additional capabilities for the user.
 733           *
 734           * The 'Additional Capabilities' section will only be enabled if
 735           * the number of the user's capabilities exceeds their number of
 736           * roles.
 737           *
 738           * @since 2.8.0
 739           *
 740           * @param bool    $enable      Whether to display the capabilities. Default true.
 741           * @param WP_User $profileuser The current WP_User object.
 742           */
 743          if ( count( $profileuser->caps ) > count( $profileuser->roles )
 744          && apply_filters( 'additional_capabilities_display', true, $profileuser )
 745          ) :
 746              ?>
 747      <h2><?php _e( 'Additional Capabilities' ); ?></h2>
 748  <table class="form-table" role="presentation">
 749  <tr class="user-capabilities-wrap">
 750      <th scope="row"><?php _e( 'Capabilities' ); ?></th>
 751      <td>
 752              <?php
 753              $output = '';
 754              foreach ( $profileuser->caps as $cap => $value ) {
 755                  if ( ! $wp_roles->is_role( $cap ) ) {
 756                      if ( '' != $output ) {
 757                          $output .= ', ';
 758                      }
 759  
 760                      if ( $value ) {
 761                          $output .= $value;
 762                      } else {
 763                          /* translators: %s: Capability name. */
 764                          $output .= sprintf( __( 'Denied: %s' ), $cap );
 765                      }
 766                  }
 767              }
 768              echo $output;
 769              ?>
 770      </td>
 771  </tr>
 772  </table>
 773      <?php endif; ?>
 774  
 775  <input type="hidden" name="action" value="update" />
 776  <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user_id ); ?>" />
 777  
 778          <?php submit_button( IS_PROFILE_PAGE ? __( 'Update Profile' ) : __( 'Update User' ) ); ?>
 779  
 780  </form>
 781  </div>
 782          <?php
 783          break;
 784  }
 785  ?>
 786  <script type="text/javascript">
 787      if (window.location.hash == '#password') {
 788          document.getElementById('pass1').focus();
 789      }
 790  </script>
 791  <?php
 792  include ( ABSPATH . 'wp-admin/admin-footer.php' );


Generated: Wed Oct 16 08:20:01 2019 Cross-referenced by PHPXref 0.7