2

I'm stuck in a WordPress redirect loop which happened after hooking into the wp_login action. The strange thing is that I've already removed the piece of code in question, cleared cookies and restarted computer and servers - but the problem remains.

They started immediately after I added this piece of code:

function check_login_redirect() {
    if( isset($_GET['redirect_to']) ) wp_redirect( esc_url($_GET['redirect_to']) );
}
add_action('wp_login', __NAMESPACE__.'\\check_login_redirect');

(I've since realised that there should have been an exit after wp_redirect.)

I hadn't recently installed any plugins or touched .htaccess files.

Initially I did have access to the admin panel, but after logging out and clearing cookies all URLs just send me into a redirect loop with these two alternating responses:

Status Code:301 Moved Permanently
Remote Address:[::1]:8080

Status Code:302 Found
Remote Address:[::1]:8080

I'm not using HTTPS.

Is there any way the code I removed could still linger? What's the best way of diagnosing the problem without access to the admin panel?

Fingers crossed this is something simple, but stuck on how to diagnose this.

Thanks!

Simon

WordPress 4.7.2, PHP 7

0

After a lot of messing around it turned out that the culprit was the plugin WPML. I'm sketchy on the exact reasons as to why it caused the redirect loop, but it had to do with some unusual settings I was using because I was trying to work around another WPML problem.

In other words editing the hook must have been a coincidence.

I emptied the active_plugins record in the wp_options table so I could access the admin panel and change the settings before reverting. If you have to do this remember to save the old value somewhere for easy recovery.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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