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


Generated : Mon Mar 18 08:20:01 2024 Cross-referenced by PHPXref