Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp_login hook not firing on login for users with a two-factor option enabled #592

Open
adriantoll opened this issue Dec 8, 2023 · 2 comments
Milestone

Comments

@adriantoll
Copy link

adriantoll commented Dec 8, 2023

Describe the bug

The wp_login hook is not firing after a successful login for users with a two-factor option enabled when using a fresh installation with only Two Factor installed.

Steps to Reproduce

  1. Install WordPress
  2. Install Two Factor
  3. Enable Email 2FA for the user and log out
  4. Add this code to the top of the functions.php file of the twentytwentyfour theme:
function namespace_user_login( $user_login, $user ) {
  error_log('wp_login');
}
add_action( 'wp_login', 'namespace_user_login', 10, 2 );
  1. Log in again
  2. Check the error log - there is no wp_login message, and there are no other error messages.

Environment information

  • WordPress version 6.4.2
  • Twenty Twenty Four theme version 1.0
  • Two Factor version 0.8.2
  • PHP version 8.1

Please confirm that you have searched existing issues in this repository.

Yes

Please confirm that you have tested with all plugins deactivated except Two-Factor.

Yes

@adriantoll adriantoll added the Bug label Dec 8, 2023
@adriantoll adriantoll mentioned this issue Dec 8, 2023
@kasparsd
Copy link
Collaborator

This plugin relies on wp_login for all of its functionality so it isn't possible that the WP core hook isn't firing:

add_action( 'wp_login', array( __CLASS__, 'wp_login' ), 10, 2 );

Add this code to the top of the functions.php file

Could it be that the functions.php of the active theme is not loaded during wp-login.php processing?

@kasparsd kasparsd closed this as not planned Won't fix, can't repro, duplicate, stale Feb 29, 2024
@kasparsd
Copy link
Collaborator

I take it back, this probably happens because of the wp_login hook priority. We're adding it at 10 and then showing the two factor screen afterwards with an exit at the end:

self::show_two_factor_login( $user );
exit;

which prevents any hooks with later priority from firing. This is the same as #297.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants