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


Generated : Sat Dec 21 08:20:01 2024 Cross-referenced by PHPXref