[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

   1  <?php
   2  /**
   3   * New User Administration Screen.
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  
   9  /** WordPress Administration Bootstrap */
  10  require_once  __DIR__ . '/admin.php';
  11  
  12  if ( is_multisite() ) {
  13      if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) ) {
  14          wp_die(
  15              '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
  16              '<p>' . __( 'Sorry, you are not allowed to add users to this network.' ) . '</p>',
  17              403
  18          );
  19      }
  20  } elseif ( ! current_user_can( 'create_users' ) ) {
  21      wp_die(
  22          '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
  23          '<p>' . __( 'Sorry, you are not allowed to create users.' ) . '</p>',
  24          403
  25      );
  26  }
  27  
  28  if ( is_multisite() ) {
  29      add_filter( 'wpmu_signup_user_notification_email', 'admin_created_user_email' );
  30  }
  31  
  32  if ( isset( $_REQUEST['action'] ) && 'adduser' === $_REQUEST['action'] ) {
  33      check_admin_referer( 'add-user', '_wpnonce_add-user' );
  34  
  35      $user_details = null;
  36      $user_email   = wp_unslash( $_REQUEST['email'] );
  37  
  38      if ( str_contains( $user_email, '@' ) ) {
  39          $user_details = get_user_by( 'email', $user_email );
  40      } else {
  41          if ( current_user_can( 'manage_network_users' ) ) {
  42              $user_details = get_user_by( 'login', $user_email );
  43          } else {
  44              wp_redirect( add_query_arg( array( 'update' => 'enter_email' ), 'user-new.php' ) );
  45              die();
  46          }
  47      }
  48  
  49      if ( ! $user_details ) {
  50          wp_redirect( add_query_arg( array( 'update' => 'does_not_exist' ), 'user-new.php' ) );
  51          die();
  52      }
  53  
  54      if ( ! current_user_can( 'promote_user', $user_details->ID ) ) {
  55          wp_die(
  56              '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
  57              '<p>' . __( 'Sorry, you are not allowed to add users to this network.' ) . '</p>',
  58              403
  59          );
  60      }
  61  
  62      // Adding an existing user to this blog.
  63      $new_user_email = array();
  64      $redirect       = 'user-new.php';
  65      $username       = $user_details->user_login;
  66      $user_id        = $user_details->ID;
  67  
  68      if ( array_key_exists( $blog_id, get_blogs_of_user( $user_id ) ) ) {
  69          $redirect = add_query_arg( array( 'update' => 'addexisting' ), 'user-new.php' );
  70      } else {
  71          if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) {
  72  
  73              wp_ensure_editable_role( $_REQUEST['role'] );
  74  
  75              $result = add_existing_user_to_blog(
  76                  array(
  77                      'user_id' => $user_id,
  78                      'role'    => $_REQUEST['role'],
  79                  )
  80              );
  81  
  82              if ( ! is_wp_error( $result ) ) {
  83                  $redirect = add_query_arg(
  84                      array(
  85                          'update'  => 'addnoconfirmation',
  86                          'user_id' => $user_id,
  87                      ),
  88                      'user-new.php'
  89                  );
  90              } else {
  91                  $redirect = add_query_arg( array( 'update' => 'could_not_add' ), 'user-new.php' );
  92              }
  93          } else {
  94              $newuser_key = wp_generate_password( 20, false );
  95              add_option(
  96                  'new_user_' . $newuser_key,
  97                  array(
  98                      'user_id' => $user_id,
  99                      'email'   => $user_details->user_email,
 100                      'role'    => $_REQUEST['role'],
 101                  )
 102              );
 103  
 104              $roles = get_editable_roles();
 105              $role  = $roles[ $_REQUEST['role'] ];
 106  
 107              /**
 108               * Fires immediately after an existing user is invited to join the site, but before the notification is sent.
 109               *
 110               * @since 4.4.0
 111               *
 112               * @param int    $user_id     The invited user's ID.
 113               * @param array  $role        Array containing role information for the invited user.
 114               * @param string $newuser_key The key of the invitation.
 115               */
 116              do_action( 'invite_user', $user_id, $role, $newuser_key );
 117  
 118              $switched_locale = switch_to_user_locale( $user_id );
 119  
 120              if ( '' !== get_option( 'blogname' ) ) {
 121                  $site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
 122              } else {
 123                  $site_title = parse_url( home_url(), PHP_URL_HOST );
 124              }
 125  
 126              /* translators: 1: Site title, 2: Site URL, 3: User role, 4: Activation URL. */
 127              $message = __(
 128                  'Hi,
 129  
 130  You\'ve been invited to join \'%1$s\' at
 131  %2$s with the role of %3$s.
 132  
 133  Please click the following link to confirm the invite:
 134  %4$s'
 135              );
 136  
 137              $new_user_email['to']      = $user_details->user_email;
 138              $new_user_email['subject'] = sprintf(
 139                  /* translators: Joining confirmation notification email subject. %s: Site title. */
 140                  __( '[%s] Joining Confirmation' ),
 141                  $site_title
 142              );
 143              $new_user_email['message'] = sprintf(
 144                  $message,
 145                  get_option( 'blogname' ),
 146                  home_url(),
 147                  wp_specialchars_decode( translate_user_role( $role['name'] ) ),
 148                  home_url( "/newbloguser/$newuser_key/" )
 149              );
 150              $new_user_email['headers'] = '';
 151  
 152              /**
 153               * Filters the contents of the email sent when an existing user is invited to join the site.
 154               *
 155               * @since 5.6.0
 156               *
 157               * @param array  $new_user_email {
 158               *     Used to build wp_mail().
 159               *
 160               *     @type string $to      The email address of the invited user.
 161               *     @type string $subject The subject of the email.
 162               *     @type string $message The content of the email.
 163               *     @type string $headers Headers.
 164               * }
 165               * @param int    $user_id        The invited user's ID.
 166               * @param array  $role           Array containing role information for the invited user.
 167               * @param string $newuser_key    The key of the invitation.
 168               *
 169               */
 170              $new_user_email = apply_filters( 'invited_user_email', $new_user_email, $user_id, $role, $newuser_key );
 171  
 172              wp_mail(
 173                  $new_user_email['to'],
 174                  $new_user_email['subject'],
 175                  $new_user_email['message'],
 176                  $new_user_email['headers']
 177              );
 178  
 179              if ( $switched_locale ) {
 180                  restore_previous_locale();
 181              }
 182  
 183              $redirect = add_query_arg( array( 'update' => 'add' ), 'user-new.php' );
 184          }
 185      }
 186  
 187      wp_redirect( $redirect );
 188      die();
 189  } elseif ( isset( $_REQUEST['action'] ) && 'createuser' === $_REQUEST['action'] ) {
 190      check_admin_referer( 'create-user', '_wpnonce_create-user' );
 191  
 192      if ( ! current_user_can( 'create_users' ) ) {
 193          wp_die(
 194              '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
 195              '<p>' . __( 'Sorry, you are not allowed to create users.' ) . '</p>',
 196              403
 197          );
 198      }
 199  
 200      if ( ! is_multisite() ) {
 201          $user_id = edit_user();
 202  
 203          if ( is_wp_error( $user_id ) ) {
 204              $add_user_errors = $user_id;
 205          } else {
 206              if ( current_user_can( 'list_users' ) ) {
 207                  $redirect = 'users.php?update=add&id=' . $user_id;
 208              } else {
 209                  $redirect = add_query_arg( 'update', 'add', 'user-new.php' );
 210              }
 211  
 212              wp_redirect( $redirect );
 213              die();
 214          }
 215      } else {
 216          // Adding a new user to this site.
 217          $new_user_email = wp_unslash( $_REQUEST['email'] );
 218          $user_details   = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email );
 219  
 220          if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) {
 221              $add_user_errors = $user_details['errors'];
 222          } else {
 223              /** This filter is documented in wp-includes/user.php */
 224              $new_user_login = apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) );
 225  
 226              if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) {
 227                  add_filter( 'wpmu_signup_user_notification', '__return_false' );  // Disable confirmation email.
 228                  add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email.
 229              }
 230  
 231              wp_ensure_editable_role( $_REQUEST['role'] );
 232  
 233              wpmu_signup_user(
 234                  $new_user_login,
 235                  $new_user_email,
 236                  array(
 237                      'add_to_blog' => get_current_blog_id(),
 238                      'new_role'    => $_REQUEST['role'],
 239                  )
 240              );
 241  
 242              if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) {
 243                  /**
 244                   * @global wpdb $wpdb WordPress database abstraction object.
 245                   */
 246                  global $wpdb;
 247  
 248                  $key      = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $new_user_email ) );
 249                  $new_user = wpmu_activate_signup( $key );
 250                  if ( is_wp_error( $new_user ) ) {
 251                      $redirect = add_query_arg( array( 'update' => 'addnoconfirmation' ), 'user-new.php' );
 252                  } elseif ( ! is_user_member_of_blog( $new_user['user_id'] ) ) {
 253                      $redirect = add_query_arg( array( 'update' => 'created_could_not_add' ), 'user-new.php' );
 254                  } else {
 255                      $redirect = add_query_arg(
 256                          array(
 257                              'update'  => 'addnoconfirmation',
 258                              'user_id' => $new_user['user_id'],
 259                          ),
 260                          'user-new.php'
 261                      );
 262                  }
 263              } else {
 264                  $redirect = add_query_arg( array( 'update' => 'newuserconfirmation' ), 'user-new.php' );
 265              }
 266  
 267              wp_redirect( $redirect );
 268              die();
 269          }
 270      }
 271  }
 272  
 273  // Used in the HTML title tag.
 274  $title       = __( 'Add User' );
 275  $parent_file = 'users.php';
 276  
 277  $do_both = false;
 278  if ( is_multisite() && current_user_can( 'promote_users' ) && current_user_can( 'create_users' ) ) {
 279      $do_both = true;
 280  }
 281  
 282  $help = '<p>' . __( 'To add a new user to your site, fill in the form on this screen and click the Add User button at the bottom.' ) . '</p>';
 283  
 284  if ( is_multisite() ) {
 285      $help .= '<p>' . __( 'Because this is a multisite installation, you may add accounts that already exist on the Network by specifying a username or email, and defining a role. For more options, such as specifying a password, you have to be a Network Administrator and use the hover link under an existing user&#8217;s name to Edit the user profile under Network Admin > All Users.' ) . '</p>' .
 286      '<p>' . __( 'New users will receive an email letting them know they&#8217;ve been added as a user for your site. This email will also contain their password. Check the box if you do not want the user to receive a welcome email.' ) . '</p>';
 287  } else {
 288      $help .= '<p>' . __( 'New users are automatically assigned a password, which they can change after logging in. You can view or edit the assigned password by clicking the Show Password button. The username cannot be changed once the user has been added.' ) . '</p>' .
 289  
 290      '<p>' . __( 'By default, new users will receive an email letting them know they&#8217;ve been added as a user for your site. This email will also contain a password reset link. Uncheck the box if you do not want to send the new user a welcome email.' ) . '</p>';
 291  }
 292  
 293  $help .= '<p>' . __( 'Remember to click the Add User button at the bottom of this screen when you are finished.' ) . '</p>';
 294  
 295  get_current_screen()->add_help_tab(
 296      array(
 297          'id'      => 'overview',
 298          'title'   => __( 'Overview' ),
 299          'content' => $help,
 300      )
 301  );
 302  
 303  get_current_screen()->add_help_tab(
 304      array(
 305          'id'      => 'user-roles',
 306          'title'   => __( 'User Roles' ),
 307          'content' => '<p>' . __( 'Here is a basic overview of the different user roles and the permissions associated with each one:' ) . '</p>' .
 308                              '<ul>' .
 309                              '<li>' . __( 'Subscribers can read comments/comment/receive newsletters, etc. but cannot create regular site content.' ) . '</li>' .
 310                              '<li>' . __( 'Contributors can write and manage their posts but not publish posts or upload media files.' ) . '</li>' .
 311                              '<li>' . __( 'Authors can publish and manage their own posts, and are able to upload files.' ) . '</li>' .
 312                              '<li>' . __( 'Editors can publish posts, manage posts as well as manage other people&#8217;s posts, etc.' ) . '</li>' .
 313                              '<li>' . __( 'Administrators have access to all the administration features.' ) . '</li>' .
 314                              '</ul>',
 315      )
 316  );
 317  
 318  get_current_screen()->set_help_sidebar(
 319      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 320      '<p>' . __( '<a href="https://wordpress.org/documentation/article/users-add-new-screen/">Documentation on Adding New Users</a>' ) . '</p>' .
 321      '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
 322  );
 323  
 324  wp_enqueue_script( 'wp-ajax-response' );
 325  wp_enqueue_script( 'user-profile' );
 326  
 327  /**
 328   * Filters whether to enable user auto-complete for non-super admins in Multisite.
 329   *
 330   * @since 3.4.0
 331   *
 332   * @param bool $enable Whether to enable auto-complete for non-super admins. Default false.
 333   */
 334  if ( is_multisite() && current_user_can( 'promote_users' ) && ! wp_is_large_network( 'users' )
 335      && ( current_user_can( 'manage_network_users' ) || apply_filters( 'autocomplete_users_for_site_admins', false ) )
 336  ) {
 337      wp_enqueue_script( 'user-suggest' );
 338  }
 339  
 340  require_once  ABSPATH . 'wp-admin/admin-header.php';
 341  
 342  if ( isset( $_GET['update'] ) ) {
 343      $messages = array();
 344      if ( is_multisite() ) {
 345          $edit_link = '';
 346          if ( ( isset( $_GET['user_id'] ) ) ) {
 347              $user_id_new = absint( $_GET['user_id'] );
 348              if ( $user_id_new ) {
 349                  $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_id_new ) ) );
 350              }
 351          }
 352  
 353          switch ( $_GET['update'] ) {
 354              case 'newuserconfirmation':
 355                  $messages[] = __( 'Invitation email sent to new user. A confirmation link must be clicked before their account is created.' );
 356                  break;
 357              case 'add':
 358                  $messages[] = __( 'Invitation email sent to user. A confirmation link must be clicked for them to be added to your site.' );
 359                  break;
 360              case 'addnoconfirmation':
 361                  $message = __( 'User has been added to your site.' );
 362  
 363                  if ( $edit_link ) {
 364                      $message .= sprintf( ' <a href="%s">%s</a>', $edit_link, __( 'Edit user' ) );
 365                  }
 366  
 367                  $messages[] = $message;
 368                  break;
 369              case 'addexisting':
 370                  $messages[] = __( 'That user is already a member of this site.' );
 371                  break;
 372              case 'could_not_add':
 373                  $add_user_errors = new WP_Error( 'could_not_add', __( 'That user could not be added to this site.' ) );
 374                  break;
 375              case 'created_could_not_add':
 376                  $add_user_errors = new WP_Error( 'created_could_not_add', __( 'User has been created, but could not be added to this site.' ) );
 377                  break;
 378              case 'does_not_exist':
 379                  $add_user_errors = new WP_Error( 'does_not_exist', __( 'The requested user does not exist.' ) );
 380                  break;
 381              case 'enter_email':
 382                  $add_user_errors = new WP_Error( 'enter_email', __( 'Please enter a valid email address.' ) );
 383                  break;
 384          }
 385      } else {
 386          if ( 'add' === $_GET['update'] ) {
 387              $messages[] = __( 'User added.' );
 388          }
 389      }
 390  }
 391  ?>
 392  <div class="wrap">
 393  <h1 id="add-new-user">
 394  <?php
 395  if ( current_user_can( 'create_users' ) ) {
 396      _e( 'Add User' );
 397  } elseif ( current_user_can( 'promote_users' ) ) {
 398      _e( 'Add Existing User' );
 399  }
 400  ?>
 401  </h1>
 402  
 403  <?php
 404  if ( isset( $errors ) && is_wp_error( $errors ) ) :
 405      $error_message = '';
 406      foreach ( $errors->get_error_messages() as $err ) {
 407          $error_message .= "<li>$err</li>\n";
 408      }
 409      wp_admin_notice(
 410          '<ul>' . $error_message . '</ul>',
 411          array(
 412              'additional_classes' => array( 'error' ),
 413              'paragraph_wrap'     => false,
 414          )
 415      );
 416  endif;
 417  
 418  if ( ! empty( $messages ) ) {
 419      foreach ( $messages as $msg ) {
 420          wp_admin_notice(
 421              $msg,
 422              array(
 423                  'id'                 => 'message',
 424                  'additional_classes' => array( 'updated' ),
 425                  'dismissible'        => true,
 426              )
 427          );
 428      }
 429  }
 430  ?>
 431  
 432  <?php
 433  if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) :
 434      $error_message = '';
 435      foreach ( $add_user_errors->get_error_messages() as $message ) {
 436          $error_message .= "<p>$message</p>\n";
 437      }
 438      wp_admin_notice(
 439          $error_message,
 440          array(
 441              'additional_classes' => array( 'error' ),
 442              'paragraph_wrap'     => false,
 443          )
 444      );
 445  endif;
 446  ?>
 447  <div id="ajax-response"></div>
 448  
 449  <?php
 450  if ( is_multisite() && current_user_can( 'promote_users' ) ) {
 451      if ( $do_both ) {
 452          echo '<h2 id="add-existing-user">' . __( 'Add Existing User' ) . '</h2>';
 453      }
 454      if ( ! current_user_can( 'manage_network_users' ) ) {
 455          echo '<p>' . __( 'Enter the email address of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ) . '</p>';
 456          $label = __( 'Email' );
 457          $type  = 'email';
 458      } else {
 459          echo '<p>' . __( 'Enter the email address or username of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ) . '</p>';
 460          $label = __( 'Email or Username' );
 461          $type  = 'text';
 462      }
 463      ?>
 464  <form method="post" name="adduser" id="adduser" class="validate" novalidate="novalidate"
 465      <?php
 466      /**
 467       * Fires inside the adduser form tag.
 468       *
 469       * @since 3.0.0
 470       */
 471      do_action( 'user_new_form_tag' );
 472      ?>
 473  >
 474  <input name="action" type="hidden" value="adduser" />
 475      <?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ); ?>
 476  
 477  <table class="form-table" role="presentation">
 478      <tr class="form-field form-required">
 479          <th scope="row"><label for="adduser-email"><?php echo esc_html( $label ); ?></label></th>
 480          <td><input name="email" type="<?php echo esc_attr( $type ); ?>" id="adduser-email" class="wp-suggest-user" value="" /></td>
 481      </tr>
 482      <tr class="form-field">
 483          <th scope="row"><label for="adduser-role"><?php _e( 'Role' ); ?></label></th>
 484          <td><select name="role" id="adduser-role">
 485              <?php wp_dropdown_roles( get_option( 'default_role' ) ); ?>
 486              </select>
 487          </td>
 488      </tr>
 489      <?php if ( current_user_can( 'manage_network_users' ) ) { ?>
 490      <tr>
 491          <th scope="row"><?php _e( 'Skip Confirmation Email' ); ?></th>
 492          <td>
 493              <input type="checkbox" name="noconfirmation" id="adduser-noconfirmation" value="1" />
 494              <label for="adduser-noconfirmation"><?php _e( 'Add the user without sending an email that requires their confirmation' ); ?></label>
 495          </td>
 496      </tr>
 497      <?php } ?>
 498  </table>
 499      <?php
 500      /**
 501       * Fires at the end of the new user form.
 502       *
 503       * Passes a contextual string to make both types of new user forms
 504       * uniquely targetable. Contexts are 'add-existing-user' (Multisite),
 505       * and 'add-new-user' (single site and network admin).
 506       *
 507       * @since 3.7.0
 508       *
 509       * @param string $type A contextual string specifying which type of new user form the hook follows.
 510       */
 511      do_action( 'user_new_form', 'add-existing-user' );
 512      ?>
 513      <?php submit_button( __( 'Add Existing User' ), 'primary', 'adduser', true, array( 'id' => 'addusersub' ) ); ?>
 514  </form>
 515      <?php
 516  } // End if is_multisite().
 517  
 518  if ( current_user_can( 'create_users' ) ) {
 519      if ( $do_both ) {
 520          echo '<h2 id="create-new-user">' . __( 'Add User' ) . '</h2>';
 521      }
 522      ?>
 523  <p><?php _e( 'Create a brand new user and add them to this site.' ); ?></p>
 524  <form method="post" name="createuser" id="createuser" class="validate" novalidate="novalidate"
 525      <?php
 526      /** This action is documented in wp-admin/user-new.php */
 527      do_action( 'user_new_form_tag' );
 528      ?>
 529  >
 530  <input name="action" type="hidden" value="createuser" />
 531      <?php wp_nonce_field( 'create-user', '_wpnonce_create-user' ); ?>
 532      <?php
 533      // Load up the passed data, else set to a default.
 534      $creating = isset( $_POST['createuser'] );
 535  
 536      $new_user_login             = $creating && isset( $_POST['user_login'] ) ? wp_unslash( $_POST['user_login'] ) : '';
 537      $new_user_firstname         = $creating && isset( $_POST['first_name'] ) ? wp_unslash( $_POST['first_name'] ) : '';
 538      $new_user_lastname          = $creating && isset( $_POST['last_name'] ) ? wp_unslash( $_POST['last_name'] ) : '';
 539      $new_user_email             = $creating && isset( $_POST['email'] ) ? wp_unslash( $_POST['email'] ) : '';
 540      $new_user_uri               = $creating && isset( $_POST['url'] ) ? wp_unslash( $_POST['url'] ) : '';
 541      $new_user_role              = $creating && isset( $_POST['role'] ) ? wp_unslash( $_POST['role'] ) : '';
 542      $new_user_send_notification = $creating && ! isset( $_POST['send_user_notification'] ) ? false : true;
 543      $new_user_ignore_pass       = $creating && isset( $_POST['noconfirmation'] ) ? wp_unslash( $_POST['noconfirmation'] ) : '';
 544  
 545      ?>
 546  <table class="form-table" role="presentation">
 547      <tr class="form-field form-required">
 548          <th scope="row"><label for="user_login"><?php _e( 'Username' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
 549          <td><input name="user_login" type="text" id="user_login" class="ltr" value="<?php echo esc_attr( $new_user_login ); ?>" aria-required="true" autocapitalize="none" autocorrect="off" autocomplete="off" maxlength="60" /></td>
 550      </tr>
 551      <tr class="form-field form-required">
 552          <th scope="row"><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
 553          <td><input name="email" type="email" id="email" value="<?php echo esc_attr( $new_user_email ); ?>" /></td>
 554      </tr>
 555      <?php if ( ! is_multisite() ) { ?>
 556      <tr class="form-field">
 557          <th scope="row"><label for="first_name"><?php _e( 'First Name' ); ?> </label></th>
 558          <td><input name="first_name" type="text" id="first_name" value="<?php echo esc_attr( $new_user_firstname ); ?>" /></td>
 559      </tr>
 560      <tr class="form-field">
 561          <th scope="row"><label for="last_name"><?php _e( 'Last Name' ); ?> </label></th>
 562          <td><input name="last_name" type="text" id="last_name" value="<?php echo esc_attr( $new_user_lastname ); ?>" /></td>
 563      </tr>
 564      <tr class="form-field">
 565          <th scope="row"><label for="url"><?php _e( 'Website' ); ?></label></th>
 566          <td><input name="url" type="url" id="url" class="code" value="<?php echo esc_attr( $new_user_uri ); ?>" /></td>
 567      </tr>
 568          <?php
 569          $languages = get_available_languages();
 570          if ( $languages ) :
 571              ?>
 572          <tr class="form-field user-language-wrap">
 573              <th scope="row">
 574                  <label for="locale">
 575                      <?php /* translators: The user language selection field label. */ ?>
 576                      <?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span>
 577                  </label>
 578              </th>
 579              <td>
 580                  <?php
 581                  wp_dropdown_languages(
 582                      array(
 583                          'name'                        => 'locale',
 584                          'id'                          => 'locale',
 585                          'selected'                    => 'site-default',
 586                          'languages'                   => $languages,
 587                          'show_available_translations' => false,
 588                          'show_option_site_default'    => true,
 589                      )
 590                  );
 591                  ?>
 592              </td>
 593          </tr>
 594          <?php endif; ?>
 595      <tr class="form-field form-required user-pass1-wrap">
 596          <th scope="row">
 597              <label for="pass1">
 598                  <?php _e( 'Password' ); ?>
 599                  <span class="description hide-if-js"><?php _e( '(required)' ); ?></span>
 600              </label>
 601          </th>
 602          <td>
 603              <input type="hidden" value=" " /><!-- #24364 workaround -->
 604              <button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Generate password' ); ?></button>
 605              <div class="wp-pwd">
 606                  <?php $initial_password = wp_generate_password( 24 ); ?>
 607                  <div class="password-input-wrapper">
 608                      <input type="password" name="pass1" id="pass1" class="regular-text ltr" autocomplete="new-password" spellcheck="false" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" />
 609                      <div style="display:none" id="pass-strength-result" aria-live="polite"></div>
 610                  </div>
 611                  <button type="button" class="button wp-hide-pw user-new-password-toggle hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
 612                      <span class="dashicons dashicons-hidden" aria-hidden="true"></span>
 613                      <span class="text"><?php _e( 'Hide' ); ?></span>
 614                  </button>
 615              </div>
 616          </td>
 617      </tr>
 618      <tr class="form-field form-required user-pass2-wrap hide-if-js">
 619          <th scope="row"><label for="pass2"><?php _e( 'Repeat Password' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
 620          <td>
 621          <input type="password" name="pass2" id="pass2" autocomplete="new-password" spellcheck="false" aria-describedby="pass2-desc" />
 622          <p class="description" id="pass2-desc"><?php _e( 'Type the password again.' ); ?></p>
 623          </td>
 624      </tr>
 625      <tr class="pw-weak">
 626          <th><?php _e( 'Confirm Password' ); ?></th>
 627          <td>
 628              <label>
 629                  <input type="checkbox" name="pw_weak" class="pw-checkbox" />
 630                  <?php _e( 'Confirm use of weak password' ); ?>
 631              </label>
 632          </td>
 633      </tr>
 634      <tr>
 635          <th scope="row"><?php _e( 'Send User Notification' ); ?></th>
 636          <td>
 637              <input type="checkbox" name="send_user_notification" id="send_user_notification" value="1" <?php checked( $new_user_send_notification ); ?> />
 638              <label for="send_user_notification"><?php _e( 'Send the new user an email about their account' ); ?></label>
 639          </td>
 640      </tr>
 641      <?php } // End if ! is_multisite(). ?>
 642      <?php if ( current_user_can( 'promote_users' ) ) { ?>
 643      <tr class="form-field">
 644          <th scope="row"><label for="role"><?php _e( 'Role' ); ?></label></th>
 645          <td><select name="role" id="role">
 646              <?php
 647              if ( ! $new_user_role ) {
 648                  $new_user_role = get_option( 'default_role' );
 649              }
 650              wp_dropdown_roles( $new_user_role );
 651              ?>
 652              </select>
 653          </td>
 654      </tr>
 655      <?php } ?>
 656      <?php if ( is_multisite() && current_user_can( 'manage_network_users' ) ) { ?>
 657      <tr>
 658          <th scope="row"><?php _e( 'Skip Confirmation Email' ); ?></th>
 659          <td>
 660              <input type="checkbox" name="noconfirmation" id="noconfirmation" value="1" <?php checked( $new_user_ignore_pass ); ?> />
 661              <label for="noconfirmation"><?php _e( 'Add the user without sending an email that requires their confirmation' ); ?></label>
 662          </td>
 663      </tr>
 664      <?php } ?>
 665  </table>
 666  
 667      <?php
 668      /** This action is documented in wp-admin/user-new.php */
 669      do_action( 'user_new_form', 'add-new-user' );
 670      ?>
 671  
 672      <?php submit_button( __( 'Add User' ), 'primary', 'createuser', true, array( 'id' => 'createusersub' ) ); ?>
 673  
 674  </form>
 675  <?php } // End if current_user_can( 'create_users' ). ?>
 676  </div>
 677  <?php
 678  require_once  ABSPATH . 'wp-admin/admin-footer.php';


Generated : Sun Oct 4 08:20:33 2026 Cross-referenced by PHPXref