From 319f8646259cd51e125157146b2529c6f50fed2b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 4 Jul 2020 21:56:54 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@48304 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-login.php | 59 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/src/wp-login.php b/src/wp-login.php index 0d906fdd2d..bad0be4cb3 100644 --- a/src/wp-login.php +++ b/src/wp-login.php @@ -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 login page.' ), + 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 login page.' ), + 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', __( 'You have successfully updated WordPress! Please log back in to see what’s new.' ), 'message' ); } elseif ( WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED === $action ) { @@ -1429,22 +1463,17 @@ switch ( $action ) {