* @param string $type A contextual string specifying which type of new user form the hook follows.
do_action( 'user_new_form', 'add-existing-user' );
<?php submit_button( __( 'Add Existing User' ), 'primary', 'adduser', true, array( 'id' => 'addusersub' ) ); ?>
} // End if is_multisite().
if ( current_user_can( 'create_users' ) ) {
echo '<h2 id="create-new-user">' . __( 'Add User' ) . '</h2>';
<p><?php _e( 'Create a brand new user and add them to this site.' ); ?></p>
<form method="post" name="createuser" id="createuser" class="validate" novalidate="novalidate"
/** This action is documented in wp-admin/user-new.php */
do_action( 'user_new_form_tag' );
<input name="action" type="hidden" value="createuser" />
<?php wp_nonce_field( 'create-user', '_wpnonce_create-user' ); ?>
// Load up the passed data, else set to a default.
$creating = isset( $_POST['createuser'] );
$new_user_login = $creating && isset( $_POST['user_login'] ) ? wp_unslash( $_POST['user_login'] ) : '';
$new_user_firstname = $creating && isset( $_POST['first_name'] ) ? wp_unslash( $_POST['first_name'] ) : '';
$new_user_lastname = $creating && isset( $_POST['last_name'] ) ? wp_unslash( $_POST['last_name'] ) : '';
$new_user_email = $creating && isset( $_POST['email'] ) ? wp_unslash( $_POST['email'] ) : '';
$new_user_uri = $creating && isset( $_POST['url'] ) ? wp_unslash( $_POST['url'] ) : '';
$new_user_role = $creating && isset( $_POST['role'] ) ? wp_unslash( $_POST['role'] ) : '';
$new_user_send_notification = $creating && ! isset( $_POST['send_user_notification'] ) ? false : true;
$new_user_ignore_pass = $creating && isset( $_POST['noconfirmation'] ) ? wp_unslash( $_POST['noconfirmation'] ) : '';
<table class="form-table" role="presentation">
<tr class="form-field form-required">
<th scope="row"><label for="user_login"><?php _e( 'Username' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
<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>
<tr class="form-field form-required">
<th scope="row"><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
<td><input name="email" type="email" id="email" value="<?php echo esc_attr( $new_user_email ); ?>" /></td>
<?php if ( ! is_multisite() ) { ?>
<th scope="row"><label for="first_name"><?php _e( 'First Name' ); ?> </label></th>
<td><input name="first_name" type="text" id="first_name" value="<?php echo esc_attr( $new_user_firstname ); ?>" /></td>
<th scope="row"><label for="last_name"><?php _e( 'Last Name' ); ?> </label></th>
<td><input name="last_name" type="text" id="last_name" value="<?php echo esc_attr( $new_user_lastname ); ?>" /></td>
<th scope="row"><label for="url"><?php _e( 'Website' ); ?></label></th>
<td><input name="url" type="url" id="url" class="code" value="<?php echo esc_attr( $new_user_uri ); ?>" /></td>
$languages = get_available_languages();
<tr class="form-field user-language-wrap">
<?php /* translators: The user language selection field label. */ ?>
<?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span>
'selected' => 'site-default',
'languages' => $languages,
'show_available_translations' => false,
'show_option_site_default' => true,
<tr class="form-field form-required user-pass1-wrap">
<?php _e( 'Password' ); ?>
<span class="description hide-if-js"><?php _e( '(required)' ); ?></span>
<input type="hidden" value=" " /><!-- #24364 workaround -->
<button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Generate password' ); ?></button>
<?php $initial_password = wp_generate_password( 24 ); ?>
<div class="password-input-wrapper">
<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" />
<div style="display:none" id="pass-strength-result" aria-live="polite"></div>
<button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
<span class="dashicons dashicons-hidden" aria-hidden="true"></span>
<span class="text"><?php _e( 'Hide' ); ?></span>
<tr class="form-field form-required user-pass2-wrap hide-if-js">
<th scope="row"><label for="pass2"><?php _e( 'Repeat Password' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
<input type="password" name="pass2" id="pass2" autocomplete="new-password" spellcheck="false" aria-describedby="pass2-desc" />
<p class="description" id="pass2-desc"><?php _e( 'Type the password again.' ); ?></p>
<th><?php _e( 'Confirm Password' ); ?></th>
<input type="checkbox" name="pw_weak" class="pw-checkbox" />
<?php _e( 'Confirm use of weak password' ); ?>
<th scope="row"><?php _e( 'Send User Notification' ); ?></th>
<input type="checkbox" name="send_user_notification" id="send_user_notification" value="1" <?php checked( $new_user_send_notification ); ?> />
<label for="send_user_notification"><?php _e( 'Send the new user an email about their account' ); ?></label>
<?php } // End if ! is_multisite(). ?>
<?php if ( current_user_can( 'promote_users' ) ) { ?>
<th scope="row"><label for="role"><?php _e( 'Role' ); ?></label></th>
<td><select name="role" id="role">
if ( ! $new_user_role ) {
$new_user_role = get_option( 'default_role' );
wp_dropdown_roles( $new_user_role );
<?php if ( is_multisite() && current_user_can( 'manage_network_users' ) ) { ?>
<th scope="row"><?php _e( 'Skip Confirmation Email' ); ?></th>
<input type="checkbox" name="noconfirmation" id="noconfirmation" value="1" <?php checked( $new_user_ignore_pass ); ?> />
<label for="noconfirmation"><?php _e( 'Add the user without sending an email that requires their confirmation' ); ?></label>
/** This action is documented in wp-admin/user-new.php */
do_action( 'user_new_form', 'add-new-user' );
<?php submit_button( __( 'Add User' ), 'primary', 'createuser', true, array( 'id' => 'createusersub' ) ); ?>
<?php } // End if current_user_can( 'create_users' ). ?>
require_once ABSPATH . 'wp-admin/admin-footer.php';