Tribe__Events__Community__Main::login_form_authentication( WP_Error|WP_User|null $user, string $username, string $password )

Filter the WordPress authentication upon login attempt to force the login error redirect to always fire.

We look for WP_Error of the type that bypasses the redirect hook for certain types of failed logins. We prefix such error(s) so the redirect hook fires while not losing the error message(s). We do not use them, but another plugin may care.

See also #


Top ↑

Parameters #

$user

(WP_Error|WP_User|null) (Required) WP_User if the user is authenticated. WP_Error or null otherwise.

$username

(string) (Required) Submitted value for username.

$password

(string) (Required) Submitted value for password.


Top ↑

Return #

(WP_Error|WP_User|null)


Top ↑

Source #

File: src/Tribe/Main.php

		public function login_form_authentication( $user, $username, $password ) {
			if (
				! $user instanceof WP_Error
				|| ! tribe_is_truthy( tribe_get_request_var( $this->login_form_id ) )
			) {
				return $user;
			}

			$ignore_codes = [
				'empty_username',
				'empty_password',
			];

			if (
				empty( $user->get_error_code() )
				|| ! in_array( $user->get_error_code(), $ignore_codes )
			) {
				return $user;
			}

			foreach ( $ignore_codes as $code ) {
				$new_key = $this->login_form_id . '_' . $code;

				foreach ( $user->errors as $key => $error ) {
					if ( $code !== $key ) {
						continue;
					}

					$user->errors[ $new_key ] = $error;

					unset( $user->errors[ $key ] );
				}
			}

			return $user;
		}

Top ↑

Changelog #

Changelog
Version Description
4.6.3 Introduced.