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


Generated: Fri Jul 19 01:00:04 2019 Cross-referenced by PHPXref 0.7.1