Page 1 of 1

Login redirect / returnto

Posted: Thu Jan 14, 2010 3:59 pm
by sta777
Hi,

I'm using this piece of code

Code: Select all

{cms_module module=FrontEndUsers form="login" returnto="forum" nocaptcha="1"}
in a Global Content Block called 'Login' to forward users to the forum once logged in, which all works great.

After adding a seperate page/section that also requires login called Articles, I would like to be able to forward the user to the relevant page depending on where they have logged in.

ie. If user logs in on forum page, they get forwarded to the forum.
If they login on the article page, they will get forwarded to the articles page.

I understand i can assign different returnto's depending on user groups, but I only have/want one user group.

I'm guessing it would be something like:

Code: Select all

{if page='articles'}
{cms_module module=FrontEndUsers form="login" returnto="articles" nocaptcha="1"}
{else}
{cms_module module=FrontEndUsers form="login" returnto="forum" nocaptcha="1"}
Any help would be greatly appreciated as I have spent hours trawling the forums and documentation.

Note: Guess I could forward to page where articles, forum etc are listed as links? hmmmm

Re: Login redirect / returnto

Posted: Thu Jan 14, 2010 6:52 pm
by jmcgin51
not sure you can do it exactly like you're trying to do it

but maybe you could insert an intermediate page that just handles the redirect based on the referring page

so the FEU call would returnto this intermediate page, and this page would simply include Smarty code to redirect the user as appropriate based on where they came from:

{if the referring page alias = 'page1'}
{redirect to page x}
{elseif the referring page alias = 'page2'}
{redirect to page y}
{elseif the referring page alias = 'page3'}
{redirect to page z}
{/if}

Re: Login redirect / returnto

Posted: Fri Jan 15, 2010 4:39 pm
by sta777
Thanks for that but I really don't understand.

There must be a simpler way of doing this?

Re: Login redirect / returnto

Posted: Fri Jan 15, 2010 4:56 pm
by Jeff
Why don't you just do this?
{cms_module module=FrontEndUsers form="login" returnto=$page_alias nocaptcha="1"}

Re: Login redirect / returnto

Posted: Fri Jan 15, 2010 5:21 pm
by sta777
Thanks ajprog, but using returnto=$page_alias returns the user to the login screen. arrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

Re: Login redirect / returnto

Posted: Fri Jan 15, 2010 5:37 pm
by Jeff
Then you don't have the template and page structure as you explained.

Re: Login redirect / returnto

Posted: Fri Jan 15, 2010 6:04 pm
by jmcgin51
ajprog wrote: Why don't you just do this?
{cms_module module=FrontEndUsers form="login" returnto=$page_alias nocaptcha="1"}
Yep - that would surely be a lot simpler than what I suggested!

I misread what he was trying to do...

Re: Login redirect / returnto

Posted: Mon Jan 18, 2010 4:57 pm
by sta777
It all sounds great but I still can't get it to work!

my url with the login form:
http://www.xxxxxxxxxxxxxxxxxxxxxxxxxx.o ... page=Login

when I add the returnto=$page_alias it ends up at the login form again but at this address:
http://www.xxxxxxxxxxxxxxxxxxxxxxxxxx.org/login/

wtf?

Re: Login redirect / returnto

Posted: Tue Jan 19, 2010 4:33 pm
by Jeff
You said you had the login on each page, and you wanted it to return to the page they logged in from. If that is how your template is setup then my suggest will do as you ask.

From your later post I would have to say your templates are messed up and your config.php or .htaccess is setup wrong.

Re: Login redirect / returnto

Posted: Wed Jan 20, 2010 9:54 am
by sta777
There is a page called login, which is hidden. All this does is call a global content block called login with the code:

Code: Select all

{cms_module module=FrontEndUsers form="login" returnto="forum" nocaptcha="1"}
Now within my layout template I have this code:

Code: Select all

<!-- start content -->
             <h1>{title}</h1>
{if $ccuser->loggedin() && $ccuser->memberof('Members')}
            {content}
 {else}
      {redirect_url to='index.php?page=Login'}
        {/if}
<!-- start content -->

Re: Login redirect / returnto

Posted: Wed Jan 20, 2010 8:14 pm
by Jeff
replace the redirect with your module or GCB call

Re: Login redirect / returnto

Posted: Fri Feb 05, 2010 5:10 pm
by sta777
Ok, so something like this?

Code: Select all


<!-- start content -->
             <h1>{title}</h1>
{if $ccuser->loggedin() && $ccuser->memberof('Members')}
            {content}
 {else}
      {module=FrontEndUsers}
        {/if}
<!-- start content -->