From e6e7f5c0f69bf6043bc4d348882c043f799c1dd0 Mon Sep 17 00:00:00 2001 From: Glendel Joubert Fyne Acosta Date: Thu, 20 May 2021 09:57:12 -0500 Subject: [PATCH] - fixed #840; --- includes/core/class-form.php | 15 +++++++++++++++ includes/core/um-actions-login.php | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/includes/core/class-form.php b/includes/core/class-form.php index 9fa80c5d..ae4c3d2a 100644 --- a/includes/core/class-form.php +++ b/includes/core/class-form.php @@ -292,6 +292,21 @@ if ( ! class_exists( 'um\core\Form' ) ) { } + /** + * Return the errors as a WordPress Error object + * @return WP_Error + */ + function get_wp_error() { + $wp_error = new \WP_Error(); + if ( $this->count_errors() > 0 ) { + foreach ( $this->errors as $key => $value ) { + $wp_error->add( $key, $value ); + } + } + return $wp_error; + } + + /** * Declare all fields */ diff --git a/includes/core/um-actions-login.php b/includes/core/um-actions-login.php index b9d12f35..dc9fb779 100644 --- a/includes/core/um-actions-login.php +++ b/includes/core/um-actions-login.php @@ -75,7 +75,7 @@ function um_submit_form_errors_hook_login( $args ) { // if there is an error notify wp if ( UM()->form()->has_error( $field ) || UM()->form()->has_error( $user_password ) || UM()->form()->count_errors() > 0 ) { - do_action( 'wp_login_failed', $user_name, UM()->form()->errors ); + do_action( 'wp_login_failed', $user_name, UM()->form()->get_wp_error() ); } } add_action( 'um_submit_form_errors_hook_login', 'um_submit_form_errors_hook_login', 10 );