Skip to content

Commit

Permalink
Login and Registration: Improve "email already exists" registration e…
Browse files Browse the repository at this point in the history
…rror message.

Adds the `wp_login_url()` login link to the Error message to be more helpful to users when their user email already is registered.

Improves the error message to more clearly communicate next step.

Follow-up to [16009], [22124], [31963].

Props andynick, costdev, dansoschin, sabernhardt, webcommsat.
Fixes #53631.

git-svn-id: https://develop.svn.wordpress.org/trunk@52074 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
hellofromtonya committed Nov 9, 2021
1 parent 2e911f4 commit 4a6df3f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/wp-includes/ms-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,14 @@ function wpmu_validate_user_signup( $user_name, $user_email ) {

// Check if the email address has been used already.
if ( email_exists( $user_email ) ) {
$errors->add( 'user_email', __( 'Sorry, that email address is already used!' ) );
$errors->add(
'user_email',
sprintf(
/* translators: %s: Link to the login page. */
__( '<strong>Error:</strong> This email address is already registered. <a href="%s">Log in</a> with this address or choose another one.' ),
wp_login_url()
)
);
}

// Has someone already signed up for this username?
Expand Down
9 changes: 8 additions & 1 deletion src/wp-includes/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -3110,7 +3110,14 @@ function register_new_user( $user_login, $user_email ) {
$errors->add( 'invalid_email', __( '<strong>Error</strong>: The email address isn&#8217;t correct.' ) );
$user_email = '';
} elseif ( email_exists( $user_email ) ) {
$errors->add( 'email_exists', __( '<strong>Error</strong>: This email is already registered. Please choose another one.' ) );
$errors->add(
'email_exists',
sprintf(
/* translators: %s: Link to the login page. */
__( '<strong>Error:</strong> This email address is already registered. <a href="%s">Log in</a> with this address or choose another one.' ),
wp_login_url()
)
);
}

/**
Expand Down

0 comments on commit 4a6df3f

Please sign in to comment.