PHP Fatal error login_header() undefined – fix
-
Hi, I got a fatal error coming from your plugin:
Call to undefined function WP2FA\\Authenticator\\login_header() in .../plugins/wp-2fa/includes/classes/Authenticator/class-login.php:813
This error showed up in wp debug.log each time someone logged in and used 2fa.
Plugin version is latest at time of writing: 2.3.0.
I fixed it on my website with some code that I based on your code in login_html() function where you do check if login_header() function exists before calling it and hooked it to your WP_2FA_PREFIX . ‘user_authenticated’ action which fires shortly before this error happens.
Code I added to my themes functions.php:
add_action( 'init', 'wyf_2fa_error_fix_init' ); function wyf_2fa_error_fix_init() { if ( defined( 'WP_2FA_PREFIX' ) ) { add_action( WP_2FA_PREFIX . 'user_authenticated', 'wyf_2fa_error_fix' ); } } function wyf_2fa_error_fix() { if ( ( ( isset( $_REQUEST['interim-login'] ) ) ? filter_var( $_REQUEST['interim-login'], FILTER_VALIDATE_BOOLEAN ) : false ) && ! function_exists( 'login_header' ) && defined( 'WP_2FA_PATH' ) ) { include_once WP_2FA_PATH . 'includes/functions/login-header.php'; } }
So pls fix this in your plugin too ??
- The topic ‘PHP Fatal error login_header() undefined – fix’ is closed to new replies.