• Resolved miraclemaker

    (@miraclemaker)


    Same issue as reported here which was closed without resolution.

    If anyone else is experiencing the same error, you can solve it by adding the below code to your theme’s functions.php, this will make sure the constant is defined before the Wordfence _userIDDetermined() function in wordfence/lib/wfLog.php is called, which is what triggers the error.

    function my_determine_current_user( $user_id ) {
    
        if (!defined('SECURE_AUTH_COOKIE')) {
            require_once(__DIR__.'/../../../wp-includes/default-constants.php');
        }
        return $user_id;
    
    }
    add_filter( 'determine_current_user', 'my_determine_current_user', 98 );
    • This topic was modified 3 years, 10 months ago by miraclemaker.
    • This topic was modified 3 years, 10 months ago by miraclemaker.
    • This topic was modified 3 years, 10 months ago by miraclemaker.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support wfpeter

    (@wfpeter)

    Thanks @miraclemaker, thanks for posting your solution that may assist fellow customers!

    Your changes above may not work in all customer cases as SECURE_AUTH_COOKIE not being defined is generally that another plugin or mu-plugin has loaded some WordPress core files out of order, causing our code to run before it should. Loading another core file, also in the wrong order, could have unintended effects but of course I’m pleased this is a solution for you and may be for others too.

    We are currently looking into a way to alert the admin when another plugin is loading assets out of order so that action can be taken if they’re not comfortable altering code.

    Thanks,

    Peter.

    In my case, it seems that this is a joint problem between Yoast and Wordfence. It ironically just happened after the latest upgrade of WordPress.

    See https://github.com/Yoast/wordpress-seo/issues/16918

    Is there any reason why you couldn’t do what they are suggesting and no do the redirect after the plugins_loaded. At the very least, to see if this would resolve the issue, because I suspect you are going to keep getting people posting issues like https://ww.wp.xz.cn/support/topic/conflict-with-yoast-seo-premium-warnings-when-performing-a-301-redirect/

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘PHP Fatal error: Uncaught Error: Undefined constant “SECURE_AUTH_COOKIE”’ is closed to new replies.