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

In this article

Authenticates the user using the WordPress auth cookie.

Parameters

$userWP_User|WP_Error|nullrequired
WP_User or WP_Error object from a previous callback. Default null.
$usernamestringrequired
Username. If not empty, cancels the cookie authentication.
$passwordstringrequired
Password. If not empty, cancels the cookie authentication.

Return

WP_User|WP_Error WP_User on success, WP_Error on failure.

Source

		);
	}

	if ( wp_password_needs_rehash( $user->user_pass, $user->ID ) ) {
		wp_set_password( $password, $user->ID );
	}

	return $user;
}

/**
 * Authenticates the user using the WordPress auth cookie.
 *
 * @since 2.8.0
 *
 * @global string $auth_secure_cookie
 *
 * @param WP_User|WP_Error|null $user     WP_User or WP_Error object from a previous callback. Default null.
 * @param string                $username Username. If not empty, cancels the cookie authentication.
 * @param string                $password Password. If not empty, cancels the cookie authentication.
 * @return WP_User|WP_Error WP_User on success, WP_Error on failure.
 */
function wp_authenticate_cookie(
	$user,
	$username,
	#[\SensitiveParameter]
	$password
) {

Changelog

VersionDescription
2.8.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.