If you tried to login to AndrewAndRachel.com, 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.
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!
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:
In my conversations with Cozmotechnical 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.