wp/wp-admin/user-new.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
--- a/wp/wp-admin/user-new.php	Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-admin/user-new.php	Wed Sep 21 18:19:35 2022 +0200
@@ -59,7 +59,7 @@
 	}
 
 	// Adding an existing user to this blog.
-	$new_user_email = $user_details->user_email;
+	$new_user_email = array();
 	$redirect       = 'user-new.php';
 	$username       = $user_details->user_login;
 	$user_id        = $user_details->ID;
@@ -100,7 +100,7 @@
 			$role  = $roles[ $_REQUEST['role'] ];
 
 			/**
-			 * Fires immediately after a user is invited to join a site, but before the notification is sent.
+			 * Fires immediately after an existing user is invited to join the site, but before the notification is sent.
 			 *
 			 * @since 4.4.0
 			 *
@@ -123,20 +123,46 @@
 %4$s'
 			);
 
+			$new_user_email['to']      = $user_details->user_email;
+			$new_user_email['subject'] = sprintf(
+				/* translators: Joining confirmation notification email subject. %s: Site title. */
+				__( '[%s] Joining Confirmation' ),
+				wp_specialchars_decode( get_option( 'blogname' ) )
+			);
+			$new_user_email['message'] = sprintf(
+				$message,
+				get_option( 'blogname' ),
+				home_url(),
+				wp_specialchars_decode( translate_user_role( $role['name'] ) ),
+				home_url( "/newbloguser/$newuser_key/" )
+			);
+			$new_user_email['headers'] = '';
+
+			/**
+			 * Filters the contents of the email sent when an existing user is invited to join the site.
+			 *
+			 * @since 5.6.0
+			 *
+			 * @param array $new_user_email {
+			 *     Used to build wp_mail().
+			 *
+			 *     @type string $to      The email address of the invited user.
+			 *     @type string $subject The subject of the email.
+			 *     @type string $message The content of the email.
+			 *     @type string $headers Headers.
+			 * }
+			 * @param int    $user_id     The invited user's ID.
+			 * @param array  $role        Array containing role information for the invited user.
+			 * @param string $newuser_key The key of the invitation.
+			 *
+			 */
+			$new_user_email = apply_filters( 'invited_user_email', $new_user_email, $user_id, $role, $newuser_key );
+
 			wp_mail(
-				$new_user_email,
-				sprintf(
-					/* translators: Joining confirmation notification email subject. %s: Site title. */
-					__( '[%s] Joining Confirmation' ),
-					wp_specialchars_decode( get_option( 'blogname' ) )
-				),
-				sprintf(
-					$message,
-					get_option( 'blogname' ),
-					home_url(),
-					wp_specialchars_decode( translate_user_role( $role['name'] ) ),
-					home_url( "/newbloguser/$newuser_key/" )
-				)
+				$new_user_email['to'],
+				$new_user_email['subject'],
+				$new_user_email['message'],
+				$new_user_email['headers']
 			);
 
 			if ( $switched_locale ) {
@@ -534,8 +560,8 @@
 		</th>
 		<td>
 			<input class="hidden" value=" " /><!-- #24364 workaround -->
-			<button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Show password' ); ?></button>
-			<div class="wp-pwd hide-if-js">
+			<button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Generate password' ); ?></button>
+			<div class="wp-pwd">
 				<?php $initial_password = wp_generate_password( 24 ); ?>
 				<span class="password-input-wrapper">
 					<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" />
@@ -544,10 +570,6 @@
 					<span class="dashicons dashicons-hidden" aria-hidden="true"></span>
 					<span class="text"><?php _e( 'Hide' ); ?></span>
 				</button>
-				<button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>">
-					<span class="dashicons dashicons-no" aria-hidden="true"></span>
-					<span class="text"><?php _e( 'Cancel' ); ?></span>
-				</button>
 				<div style="display:none" id="pass-strength-result" aria-live="polite"></div>
 			</div>
 		</td>
@@ -555,7 +577,8 @@
 	<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>
 		<td>
-		<input name="pass2" type="password" id="pass2" autocomplete="off" />
+		<input name="pass2" type="password" id="pass2" autocomplete="off" aria-describedby="pass2-desc" />
+		<p class="description" id="pass2-desc"><?php _e( 'Type the password again.' ); ?></p>
 		</td>
 	</tr>
 	<tr class="pw-weak">
@@ -581,7 +604,7 @@
 		<td><select name="role" id="role">
 			<?php
 			if ( ! $new_user_role ) {
-				$new_user_role = ! empty( $current_role ) ? $current_role : get_option( 'default_role' );
+				$new_user_role = get_option( 'default_role' );
 			}
 			wp_dropdown_roles( $new_user_role );
 			?>