-//Load up the passed data, else set to a default.
-foreach ( array('user_login' => 'login', 'first_name' => 'firstname', 'last_name' => 'lastname',
- 'email' => 'email', 'url' => 'uri', 'role' => 'role') as $post_field => $var ) {
- $var = "new_user_$var";
- if ( ! isset($$var) )
- $$var = isset($_POST[$post_field]) ? stripslashes($_POST[$post_field]) : '';
-}
-$new_user_send_password = !$_POST || isset($_POST['send_password']);
+/**
+ * Fires at the end of the new user form.
+ *
+ * Passes a contextual string to make both types of new user forms
+ * uniquely targetable. Contexts are 'add-existing-user' (Multisite),
+ * and 'add-new-user' (single site and network admin).
+ *
+ * @since 3.7.0
+ *
+ * @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' ) ); ?>
+</form>
+<?php
+} // is_multisite()
+
+if ( current_user_can( 'create_users') ) {
+ if ( $do_both )
+ echo '<h2 id="create-new-user">' . __( 'Add New 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"<?php
+ /** 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' ); ?>
+<?php
+// 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'] ) : '';
+