From dc60f7c76f6362ae2315731289c6dc9a77c05722 Mon Sep 17 00:00:00 2001 From: Ryan Griffith Date: Sun, 25 Aug 2019 16:35:14 -0700 Subject: [PATCH] Making wp_signon errors visible to users. Signon errors can occur in situations beyond just those generated from RC. We should be carrying those users forward to the UI. --- includes/forms.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/includes/forms.php b/includes/forms.php index 80d39b9..ff02a3d 100644 --- a/includes/forms.php +++ b/includes/forms.php @@ -144,15 +144,20 @@ function rc_process_login_form() { $redirect = ! empty( $_POST['rc_redirect'] ) ? $_POST['rc_redirect'] : home_url(); - wp_signon( array( + $wp_signon_result = wp_signon( array( 'user_login' => $user->user_login, 'user_password' => $_POST['rc_user_pass'], 'remember' => isset( $_POST['rc_user_remember'] ) ) ); - wp_safe_redirect( esc_url_raw( $redirect ) ); + if( is_wp_error($wp_signon_result) ){ + rc_errors()->add( 'wp_signin_error' , $wp_signon_result->get_error_message(), 'login' ); + $errors = rc_errors()->get_error_messages(); + }else{ + wp_safe_redirect( esc_url_raw( $redirect ) ); - exit; + exit; + } } } add_action( 'init', 'rc_process_login_form' ); @@ -660,4 +665,4 @@ function rc_validate_user_data( array $data ) { } return $user; -} \ No newline at end of file +}