Page 1 of 1

Front End Users module - redirect to last page

Posted: Tue Jun 01, 2010 1:14 pm
by gap_tooth_clan
If you are using FEU module and you need to redirect back to the page where a user was prior to being redirected to login use this tag

call it from your template with {Redirection myPageAlias="$page_alias"}

Make a UDT with a name Redirection

Code: Select all

if ($_SESSION['last_page'] == ''){
  $_SESSION['last_page_2'] = 'home';
} else {
  $_SESSION['last_page_2'] = $_SESSION['last_page'];
}

if ($_SESSION['current_page'] == ''){
  $_SESSION['last_page'] = 'home';
} else {
  $_SESSION['last_page'] = $_SESSION['current_page'];
}

$_SESSION['current_page'] = $params['myPageAlias'];

$smarty->assign('last_page_2', $_SESSION['last_page_2']);
and on the preferences tab for FEU set the redirect to page after login field to {$last_page_2}

job done

Re: Front End Users module - redirect to last page

Posted: Tue Jun 01, 2010 1:25 pm
by calguy1000
FEU has this capability built in.

Re: Front End Users module - redirect to last page

Posted: Wed Jun 30, 2010 5:45 pm
by rvaneerd
hi CalGuy,
calguy1000 wrote: FEU has this capability built in.
??? Can you please explain / point me in the right direction where this can be realized?
I scanned all settings / preferences of the FEU but couldn't find it  :-[

Regards,
Rob

Re: Front End Users module - redirect to last page

Posted: Fri Oct 22, 2010 9:41 pm
by kissack
rvaneerd wrote: hi CalGuy,
calguy1000 wrote: FEU has this capability built in.
??? Can you please explain / point me in the right direction where this can be realized?
I scanned all settings / preferences of the FEU but couldn't find it  :-[

Regards,
Rob
I cant find it either :-(

Re: Front End Users module - redirect to last page

Posted: Tue Nov 09, 2010 4:14 am
by ESBertrand
From what I see, this is not built-in to FEU - at least not in the latest FEU I have (version 1.12.5).  I tried not setting the "redirect after login" value, which seemed the most logical default behavior.

CalGuy - if this is built-in, could you let us know how to enable this behavior?  Without an automatic redirect after login back to the page the user requested, the UX is greatly diminished.

Currently, we have this code just after the starting BODY tag in our template (got it from the FEU docs, I believe):

Code: Select all

{if !$ccuser->loggedin() || ($ccuser->loggedin() && !$ccuser->memberof('Approved Members'))}{redirect_page page='member-login'}{/if}
I'm going to try to work gap_tooth_clan's suggestion into this.

Erik

Re: Front End Users module - redirect to last page

Posted: Tue Nov 09, 2010 1:35 pm
by Peciura
My login form is always visible and user after login/logout is redirected to a page visited just before login/logout procedure.

Users & Groups » Frontend User Management > Builtin Authentication > Redirection Settings
paste {$page_alias} to fields
"PageID/Alias to jump to after login" and
"PageID/Alias to jump to after logout"

Re: Front End Users module - redirect to last page

Posted: Tue Nov 09, 2010 1:59 pm
by ESBertrand
Thanks for the reply, Peciura.  Your method works because you have the login fields on every single page.  We're not doing that since we don't want to figure the login so prominently.

If anyone else is doing this with just a single login page (hence the need for redirection back to the originally-requested page), please post!

Erik

Re: Front End Users module - redirect to last page

Posted: Tue Nov 16, 2010 2:59 am
by ESBertrand
I've tried to get this to work by setting a session variable via PHP, but no go so far.  Doesn't help that I'm a .NET developer working in a PHP/Smarty world...  anyone have any tips?

Am I right that this should be workable simply by doing the following:

1.  Add code to the "secure page" template to save the page alias (the value of the "page" querystring variable) to a session variable.  Something like this:

Code: Select all

{$_SESSION['LastPage'] = $params['page']}
2.  Add code to the page that hosts the login form, that will set a smarty variable with the value of the session variable set in step 1, like this:

Code: Select all

{$smarty->assign('DestPage', $_SESSION['LastPage'])}
3.  Set the "redirect after login" setting within FEU to the smarty variable set in step 2 (i.e. $DestPage)

I'm getting smarty errors with at least step 2, and probably step 1, too (there's a redirect that follows the listed line, so I'm probably just not seeing that error).  Any suggestions?  Help!

Erik

Re: Front End Users module - redirect to last page

Posted: Tue Nov 16, 2010 10:05 am
by Peciura
Idea is to save page alias of any visited page but login page. Make sure module CGSimpleSmarty is installed.
{if $page_alias!='login_page_alias'}
{session_put var='saved_alias' value=$page_alias}
{/if}
Paste
{$smarty.session.saved_alias}
to fields
"PageID/Alias to jump to after login" and
"PageID/Alias to jump to after logout".

Additionally specify default page if for some reasons page alias was not saved to session.
{$smarty.session.saved_alias|default:'default_alias'}