From 722df60bcd42c43a6dc955951ef82a1639741bd2 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 4 Jul 2020 21:58:03 +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. Built from https://develop.svn.wordpress.org/trunk@48304 git-svn-id: http://core.svn.wordpress.org/trunk@48073 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/version.php | 2 +- wp-login.php | 59 ++++++++++++++++++++++++++++++----------- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index ebeea3479d..dd7ce7c95c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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. diff --git a/wp-login.php b/wp-login.php index 0d906fdd2d..bad0be4cb3 100644 --- a/wp-login.php +++ b/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 ) {