0

Wordpress website keeps on redirecting to login page after I enter correct login credentials. When I input the wrong credentials, it shows an error stating that the credentials are not correct. So I enabled the debug mode to see what appears as the error message and the following errors are being produced whenever I try to access wp-admin with debug mode enabled. When I disable debug mode, the login page does appear.

Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /xd1/homes/hash/22/80/a28022/88/82/u108288/XXX.co.zw/www/wp-content/plugins/anps_theme_plugin/plugin-updates/plugin-update-checker.php on line 833

Warning: Cannot modify header information - headers already sent by (output started at /xd1/homes/hash/22/80/a28022/88/82/u108288/XXX.co.zw/www/wp-content/plugins/anps_theme_plugin/plugin-updates/plugin-update-checker.php:833) in /xd1/homes/hash/22/80/a28022/88/82/u108288/XXX.co.zw/www/wp-includes/pluggable.php on line 1265

Warning: Cannot modify header information - headers already sent by (output started at /xd1/homes/hash/22/80/a28022/88/82/u108288/XXX.co.zw/www/wp-content/plugins/anps_theme_plugin/plugin-updates/plugin-update-checker.php:833) in /xd1/homes/hash/22/80/a28022/88/82/u108288/XXX.co.zw/www/wp-includes/pluggable.php on line 1268 ```
1
  • It is just a deprecation warning and should not change if you can login or not. Did you try deactivating the anps_theme_plugin plugin and trying again?
    – kero
    Jan 6, 2021 at 13:16

1 Answer 1

1

The plugin update checker is outputting something before the login redirection. The function wp_redirect() has to be called before anything gets echoed onto the screen. Try disabling the anps_theme_plugin and see if your login problem resolves.

Edit: I use a more complicated logging system that prints out nice and pretty on a custom admin page, but here is a temporary hack to the function wp_redirect() in pluggable.php This will stop execution immediately upon the error and tell you the last ten functions leading up to it. That backtrace will be an array.

The first and last lines are untouched, so you can see their location.

$x_redirect_by = apply_filters( 'x_redirect_by', $x_redirect_by, $status, $location );
    if ( is_string( $x_redirect_by ) ) {
        if (! headers_sent($filename, $linenum)){
            header( "X-Redirect-By: $x_redirect_by" );
        } else {
            $backtrace = debug_backtrace(FALSE, 10);
            echo '<br><br><br><pre>';
            print_r($backtrace);
            wp_die();
        }
    }
    if (! headers_sent($filename, $linenum)){
      header( "Location: $location", true, $status );
    } else {
        $backtrace = debug_backtrace(FALSE, 10);
        echo '<br><br><br><pre>';
        print_r($backtrace);
        wp_die();
        }

    return true;
2
  • I have renamed the entire plugins folder, the redirect error is still taking place. If I rename the anpa_theme_plugin folder, will that not cause any config changes that might be catastrophic? Jan 7, 2021 at 5:36
  • I would definitely switch to a default theme for a minute to check if that theme is the problem, and obviously look for an update. When I was chasing down my culprit on a headers sent error, I recorded the stack trace to find it was my security software hooking too early, outputting something and then when the client got redirected by my check, it was too late to use wp_redirect(). But in my case the error was only happening to nefarious robot visitors. No legit page had the problem. Hold on I'll amend my answer with the stack trace scheme I used.
    – Elkrat
    Jan 7, 2021 at 23:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.