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


Generated : Sat Sep 26 08:20:01 2020 Cross-referenced by PHPXref