From 10f9e9dd1b25bd8b85569da0007c269a52f6f1e0 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Mon, 29 Jul 2024 08:28:54 +0000 Subject: [PATCH] Patch in a hook to two-factor. See https://github.com/WordPress/two-factor/pull/620 --- revalidation/index.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/revalidation/index.php b/revalidation/index.php index 93056497..c7f7e181 100644 --- a/revalidation/index.php +++ b/revalidation/index.php @@ -117,4 +117,25 @@ function clear_cookie() { } setcookie( COOKIE_NAME, '', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), false ); -} \ No newline at end of file +} + +/** + * Temporarily abuse a filter to patch in an action. + * + * This filter is run just before the login form is output. + * + * @see https://github.com/WordPress/two-factor/pull/620 + */ +add_filter( 'login_title', static function( $title ) { + if ( + is_user_logged_in() && + isset( $_REQUEST['action'] ) && + 'revalidate_2fa' == $_REQUEST['action'] && + ! get_revalidation_status()['needs_revalidate'] && + ! did_action( 'two_factor_user_revalidated' ) + ) { + do_action( 'two_factor_user_revalidated', wp_get_current_user(), false ); + } + + return $title; +} ); \ No newline at end of file