diff --git a/social-connect.php b/social-connect.php
index 825d936..2e79e18 100644
--- a/social-connect.php
+++ b/social-connect.php
@@ -226,12 +226,7 @@ function sc_social_connect_process_login( $is_ajax = false ) {
update_user_meta( $user_id, $sc_provider_identity_key, $sc_provider_identity );
}
} else {
- add_filter( 'wp_login_errors', function ( $errors ) {
- $errors->errors = array();
- $errors->add( 'registration_disabled', __( 'ERROR: Registration is disabled.', 'social-connect' ) );
-
- return $errors;
- });
+ add_filter( 'wp_login_errors', 'sc_login_errors' );
return;
}
@@ -250,6 +245,20 @@ function sc_social_connect_process_login( $is_ajax = false ) {
exit();
}
+/**
+ * Add error message when user try to login
+ * with an nonexistent e-mail and registration is disabled
+ *
+ * @param WP_Error $errors
+ * @return WP_Error
+ */
+function sc_login_errors( $errors ) {
+ $errors->errors = array();
+ $errors->add( 'registration_disabled', __( 'ERROR: Registration is disabled.', 'social-connect' ) );
+
+ return $errors;
+}
+
function sc_get_unique_username($user_login, $c = 1) {
if ( username_exists( $user_login ) ) {
if ($c > 5)