Page 1 of 1
Front End User - redirect after login
Posted: Fri Jul 03, 2020 3:59 pm
by johnboyuk1
Hi. I'm sure this must have been covered somewhere but I cant find anything...
How do I redirect to a page after login? Default set up is for FEU to stay on the same page and just replace the login form with a 'login successful' message. What I need to do is redirect to a protected page...
The help file gives this as an example:
Code: Select all
{if !empty($final_message)}
{cms_selflink href='members' assign='members_page_url'}
{redirect_url to=$members_page_url}
{else}
something else
{/if}
I cant get this to work though?! I'm assuming it goes in the page template - I've put under the {FrontEndUsers} tag in my page template
This must be something simple ... please help me
Thanks!
Re: Front End User - redirect after login
Posted: Fri Jul 03, 2020 4:45 pm
by velden
I think you should put that logic in the assets/module_custom/FrontEndUsers/templates/orig_loginform.tpl
If that folder and file don't exist yet create the folder structure and copy the orig_loginform.tpl file from /modules/FrontEndUsers/templates/orig_loginform.tpl
https://docs.cmsmadesimple.org/customiz ... -templates
Re: Front End User - redirect after login
Posted: Fri Jul 03, 2020 5:15 pm
by johnboyuk1
Thanks Velden - I will take a look
If anyone can advise a way of doing within page template that would be good
Re: Front End User - redirect after login
Posted: Fri Jul 03, 2020 5:33 pm
by DIGI3
Velden's suggestion is probably best, but if you need it in the page template you can always change the {if} part to check for something that's available to it, something like (not tested):
Code: Select all
{$uid=feu_smarty::get_current_userid()}
{if $uid > 0}
{redirect_page page='your-page-alias'}
{/if}
Re: Front End User - redirect after login
Posted: Fri Jul 03, 2020 7:55 pm
by johnboyuk1
Cool thanks - will look at that
Re: Front End User - redirect after login
Posted: Mon Jul 06, 2020 11:35 am
by johnboyuk1
ok, I've tried placing the following code (taken from the help file)
in the login form.tpl as a test
Code: Select all
{if !empty($final_message)}
I'm going to redirect you
{else}
Error
{/if}
However ... it doesnt seem to work - I get the else statement run ie the word 'error' displays after logging in
So I tried
Code: Select all
{if !empty($user_info->id > 0)}
I'm going to redirect you
{else}
Error
{/if}
which does seem to work. I'm not sure why the method from the help file doest work... is there any reason I cant use my modified method above? And if not, then posting this in case its useful to someone else!
Re: Front End User - redirect after login
Posted: Mon Jul 06, 2020 12:37 pm
by velden
I'd consider changing (and testing):
into:
Alternatively:
Code: Select all
{if !empty($user_info) && $user_info->id > 0)}
Re: Front End User - redirect after login
Posted: Mon Jul 06, 2020 12:40 pm
by johnboyuk1
Thanks Velden - will test