Skip to content

Commit

Permalink
Mail: Improve the user experience when the password reset email canno…
Browse files Browse the repository at this point in the history
…t 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


git-svn-id: https://develop.svn.wordpress.org/trunk@45404 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
johnbillion committed May 24, 2019
1 parent a3fbc75 commit 3834909
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/wp-login.php
Expand Up @@ -45,7 +45,7 @@ function login_header( $title = 'Log In', $message = '', $wp_error = null ) {
}

// 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.
*
Expand Down Expand Up @@ -426,7 +426,16 @@ function retrieve_password() {
$message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data );

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;
Expand Down

0 comments on commit 3834909

Please sign in to comment.