Service Notice: Login Redirect Issue Fixed

If you tried to login to, you may have noticed that you’d essentially get stuck at a “You’re now logged in page” and you had to figure out how to get back to whatever you were trying to look at.

No more!

Whenever you login now you will automatically be redirected back to the page you viewing.

As always, if you ever encounter things like this please let us know…even if they seem trivial!

Technical details

We use Cozmo’s Profile Builder Hobbyist plugin to manage the user registration and access limitations on this site. It works quite well for this little experiment, and the support has been outstanding when I’ve had questions.

For some reason though users were not being redirected back to the page they were viewing after they logged in, instead just seeing a generic “You are currently logged in as <<username>>” page:

At first I thought the wppb_cpm_redirect parameter was the issue, but I think that’s just an artifact of using the Custom Profile Menu add-on for Profile Builder. Looking a bit deeper, I did see a wppb_referer_url parameter that is set by Profile Builder and sent with the login request, so the necessary data is present to successfully redirect.

If you have the Pro version of Profile Builder (instead of the Hobbyist version, like we do) then you can use the Custom Redirect module. But it also has a lot of other features we wouldn’t use (e.g. redirect based on username, etc).

There is also a redirect_url parameter for the wppb-login shortcode, but that just defaults to the current page and not the referring page (which is what would be needed).

I’ve filed a support request ticket to clarify if redirecting after login is the intended function or not and will update this post with their response.

In the meantime, since wppb_referer_url is the data needed I’ve whipped up this little bit of code to solve the problem by hooking into WordPress’ login_redirect filter:

function fergcorp_wppbc_user_login_redirect( $url, $request ){
    if( isset( $_POST['wppb_referer_url'] ) ) {
        $url = esc_url_raw($_POST['wppb_referer_url']);
    return $url;
add_filter( 'login_redirect', 'fergcorp_wppbc_user_login_redirect', 10, 3 );

Problem solved.

Update: 10 March 2020

In my conversations with Cozmo technical support, they were able to confirm that this functionality is currently not included in the Hobbyist version, but is included in the Pro version via the aforementioned Custom Redirect module.

Here’s the updated gist that includes my custom tweaks for Cozmo’s Profile Builder Hobbyist:


Leave a Reply