I am new to working with Expression Engine, so this might not be possible. The site I am working on has some pages that are private to members only. I'm assuming this is a built in feature of Expression Engine and not some type of add-on. When a member who is not logged in reaches a page which requires login, I would like them to be redirected back to the page they were on after they log in. Currently it is redirecting them to a specific member page (and I'm not sure where that is configured).
Update:
After further investigation, there are two "member" modules installed: Freemember
and Member
. There is a link to a custom login page and in the html there is a {login_form}
tag. I can't find where or who defines this variable so I don't know what to do next.
Update:
I found the source of the {login_form}
tag. This was being defined in a template using a plugin called CE variables
. Here's a sample of the template:
{exp:ce_vars:set_content name="login_form"}
{exp:freemember:login form_id="login" return="/member-resources" error_handling="inline" error_delimiters='<small>|</small>'}
...some html...
{/exp:freemember:login}
{/exp:ce_vars:set_content}
Obviously, I found the source of the redirect (the return
attribute). So now it is a matter of passing the "return to URL" in the link to the login form.
Solution:
Freemember
provides a PREVIOUS_URL
constant that you can use instead:
{exp:freemember:login return="PREVIOUS_URL"}
return
param as I demonstrated with Profile:Edit. Pass your current URL to the login page from your protected pages, and fill in thereturn
param as prescribed. github.com/expressodev/freemember/wiki/Login-Tag