Login and Registration: Hide the login form on the "check your email" step of new user registration or password reset.

This aims to reduce some confusion and make it clearer that the email should be checked before attempting to log in right away.

Props rianrietveld, pratik028, bdbch, johnbillion, hankthetank, yashrs, williampatton, audrasjb, bmartinent, florianatwhodunit, henry.wright, birgire, SergeyBiryukov.
Fixes #40605, #41514.
Built from https://develop.svn.wordpress.org/trunk@48304


git-svn-id: http://core.svn.wordpress.org/trunk@48073 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-07-04 21:58:03 +00:00
parent 324cd48507
commit 722df60bcd
2 changed files with 45 additions and 16 deletions

View File

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

View File

@ -492,6 +492,10 @@ if ( isset( $_GET['key'] ) ) {
$action = 'resetpass';
}
if ( isset( $_GET['checkemail'] ) ) {
$action = 'checkemail';
}
$default_actions = array(
'confirm_admin_email',
'postpass',
@ -501,6 +505,7 @@ $default_actions = array(
'resetpass',
'rp',
'register',
'checkemail',
'login',
'confirmaction',
WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED,
@ -1130,6 +1135,39 @@ switch ( $action ) {
login_footer( 'user_login' );
break;
case 'checkemail':
$redirect_to = admin_url();
$errors = new WP_Error();
if ( 'confirm' === $_GET['checkemail'] ) {
$errors->add(
'confirm',
sprintf(
/* translators: %s: Link to the login page. */
__( 'Check your email for the confirmation link, then visit the <a href="%s">login page</a>.' ),
wp_login_url()
),
'message'
);
} elseif ( 'registered' === $_GET['checkemail'] ) {
$errors->add(
'registered',
sprintf(
/* translators: %s: Link to the login page. */
__( 'Registration complete. Please check your email, then visit the <a href="%s">login page</a>.' ),
wp_login_url()
),
'message'
);
}
/** This action is documented in wp-login.php */
$errors = apply_filters( 'wp_login_errors', $errors, $redirect_to );
login_header( __( 'Log In' ), '', $errors );
login_footer();
break;
case 'confirmaction':
if ( ! isset( $_GET['request_id'] ) ) {
wp_die( __( 'Missing request ID.' ) );
@ -1328,10 +1366,6 @@ switch ( $action ) {
$errors->add( 'loggedout', __( 'You are now logged out.' ), 'message' );
} elseif ( isset( $_GET['registration'] ) && 'disabled' === $_GET['registration'] ) {
$errors->add( 'registerdisabled', __( 'User registration is currently not allowed.' ) );
} elseif ( isset( $_GET['checkemail'] ) && 'confirm' === $_GET['checkemail'] ) {
$errors->add( 'confirm', __( 'Check your email for the confirmation link.' ), 'message' );
} elseif ( isset( $_GET['checkemail'] ) && 'registered' === $_GET['checkemail'] ) {
$errors->add( 'registered', __( 'Registration complete. Please check your email.' ), 'message' );
} elseif ( strpos( $redirect_to, 'about.php?updated' ) ) {
$errors->add( 'updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what&#8217;s new.' ), 'message' );
} elseif ( WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED === $action ) {
@ -1429,22 +1463,17 @@ switch ( $action ) {
<p id="nav">
<?php
if ( ! isset( $_GET['checkemail'] ) || 'confirm' !== $_GET['checkemail'] ) {
if ( get_option( 'users_can_register' ) ) {
$registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
if ( get_option( 'users_can_register' ) ) {
$registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
/** This filter is documented in wp-includes/general-template.php */
echo apply_filters( 'register', $registration_url );
/** This filter is documented in wp-includes/general-template.php */
echo apply_filters( 'register', $registration_url );
echo esc_html( $login_link_separator );
}
?>
<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a>
<?php
echo esc_html( $login_link_separator );
}
?>
<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a>
</p>
<?php
}