Mail: Improve the user experience when the password reset email cannot be sent.

This introduces a link to the support page for resetting your password, and improves the error by bringing it into the login page instead of a `wp_die()`.

Props neelpatel7295, estelaris, desrosj

Built from https://develop.svn.wordpress.org/trunk@45404


git-svn-id: http://core.svn.wordpress.org/trunk@45215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2019-05-24 22:14:52 +00:00
parent b77cf42c0b
commit b3e297925c
2 changed files with 12 additions and 3 deletions

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.3-alpha-45403'; $wp_version = '5.3-alpha-45404';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -45,7 +45,7 @@ function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
} }
// Shake it! // Shake it!
$shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' ); $shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password', 'retrieve_password_email_failure' );
/** /**
* Filters the error codes array for shaking the login form. * Filters the error codes array for shaking the login form.
* *
@ -426,7 +426,16 @@ function retrieve_password() {
$message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data ); $message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data );
if ( $message && ! wp_mail( $user_email, wp_specialchars_decode( $title ), $message ) ) { if ( $message && ! wp_mail( $user_email, wp_specialchars_decode( $title ), $message ) ) {
wp_die( __( 'The email could not be sent. Possible reason: your host may have disabled the mail() function.' ) ); /* translators: URL to support page for resetting your password */
$support = __( 'https://wordpress.org/support/article/resetting-your-password/' );
$errors->add(
'retrieve_password_email_failure',
sprintf(
__( '<strong>ERROR</strong>: The e-mail could not be sent. Your site may not be correctly configured to send e-mails. <a href="%s">Get support for resetting your password</a>.' ),
esc_url( $support )
)
);
return $errors;
} }
return true; return true;