Skip to content

Function

Enforce the login type.

tml_enforce_login_type( null|WP_Error|WP_User $user, string $username, string $password )

Parameters

$user null|WP_Error|WP_User
$username string
$password string

Return

null|WP_User|WP_Error

Source

function tml_enforce_login_type( $user, $username, $password ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- $username/$password are unused but required by the authenticate filter signature.
    if ( tml_is_email_login_type() && null === $user ) {
        return new WP_Error( 'invalid_email', __( 'Unknown email address. Check again or try your username.' ) ); // phpcs:ignore WordPress.WP.I18n.MissingArgDomain -- reusing WP core's translated string verbatim (see wp-includes/user.php), not a TML-specific string.
    }
    return $user;
}

Uses

Changelog

VersionDescription
7.0 Introduced.