Login redirect from single.php does NOT overrides default redirect (5 posts)

  1. bmeisler
    Posted 5 years ago #

    I'm forcing users to login before they can access content. It was pretty easy to figure out how to redirect them to stay on the same page:

    The content you're trying to access requires you to /wp-login.php?redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']); ?>">log in.

    However, when NEW users register, I make them verify their subscription via email (I'm using Register Plus Redux for this part). When they click the verification link and login, they're brought to the default Profile page. Like many people, I think this is disconcerting to many non-tech folks.

    I figured out how to go to my home page on login by adding the following to functions.php:

    add_filter('login_redirect', 'plugin_admin_redirect');

    function plugin_admin_redirect($redirect_to, $url_redirect_to = '', $user = null) {
    return '/';

    The PROBLEM: now the login redirect on the page of origin doesn't work! It too will go to the home page!

    Can anybody tell me how I might tweak the above filter so that a login from single.php overrides the otherwise default behavior?

    Even better would be if login after registration brought me back to my page of origin. But I've had a lot of difficulty passing the permalink over to Register Plus and then getting it to write the link properly in the email.

    If anybody could help with this I'd appreciate it enormously! Thanks in advance!

  2. Hyipper
    Posted 5 years ago #

    Hey, I have the same challenge. I tried to overcome it by filling in the Registration Redirect field, I assumed that that was what it was for, but it just seems to ignore that.

  3. bmeisler
    Posted 5 years ago #

    Glad to see I'm not the only one! I actually think that this would be a common problem, as the default post login screen (Profile) is some seriously bad UX...

    I can't expect Radiok to fix this, as it would probably be pretty complicated.

    The easy fix, IMHO, would be to override the filter I placed in functions.php, so that I'd allow my "custom" redirect (going back to page of origin) in the case that the function was called from single.php (i.e., subscriber-only content pages). But this is a bit beyond my WordPress/PHP chops at this point.

    Can anybody help? Maybe I should post this as a generic help request for filters...if I ever figure it out, I'll definitely post it...

  4. Hyipper
    Posted 5 years ago #

    I just found something useful. have a look at


  5. Grubbyseismic
    Posted 5 years ago #

    I don't know how much luck has been had finding a solution, but adding editing anything to FUNCTIONS.PHP will make any updates a little more difficult...

    I think (I'm no PHP genius mind!) this is a valid feature-request; possibly including which page users are redirected back from any Verification e-mails...

Topic Closed

This topic has been closed to new replies.

About this Topic