Change landing page after successful login

Started by BRJP, May 05, 2014, 02:03:32 PM

BRJP

Dear All,

We want to make a small amendment to the landing page post successful login. 

At current, the user is directed to root/ once they log in.  However, we would like them to be taken straight to the clientarea/ page.  We have looked in pages such as login.tpl and cannot see how to amend the landing page post login.  It seems that it might be calling a JS function but not sure where!

Any help would be greatly appreciated.

Thanks in advance.
Kind regards,
Bradley Porter
--------------------
Find out more about SaneChoice Services at: https://www.sanechoice.cloud/

BRJP

Anyone got any ideas within the community?
Kind regards,
Bradley Porter
--------------------
Find out more about SaneChoice Services at: https://www.sanechoice.cloud/

DeLeTe Me

Hey BRJP,

I found the solution!

includes/extend/hooks - there is a file called after_clientlogin_01.php.sample ... copy it, and remove the .sample part

Then add this below in the file:

function Redirect($url, $permanent = false)
{
    if (headers_sent() === false)
    {
       header('Location: ' . $url, true, ($permanent === true) ? 301 : 302);
    }

    exit();
}

Redirect('/clientarea/', false);

BRJP

Thanks for this but it did not seem to have any effect.

I did as you said, but when I login it still goes to root.   This is the file I created (renamed to after_clientlogin_01.php and left in hook directory) and here is the output:

<?php
function Redirect($url, $permanent = false)
{
    if (headers_sent() === false)
    {
       header('Location: ' . $url, true, ($permanent === true) ? 301 : 302);
    }

    exit();
}

Redirect('?/clientarea/', false);


What did I do wrong?
Kind regards,
Bradley Porter
--------------------
Find out more about SaneChoice Services at: https://www.sanechoice.cloud/


BRJP

Thank you. 

It does say that these are disabled as a they represent a security risk.  How much of a security risk is this?
Kind regards,
Bradley Porter
--------------------
Find out more about SaneChoice Services at: https://www.sanechoice.cloud/

DeLeTe Me

Your welcome..

I don't know how much risk there is, more than regular PHP usage. But only one way to find out :)

BRJP

#7
Indeed!  Ill do some checking and also talk to a local developer and see what the risk is. 

I will also pass the output to this forum.
Kind regards,
Bradley Porter
--------------------
Find out more about SaneChoice Services at: https://www.sanechoice.cloud/

Fusionhost

I am looking forward to hear the response that you are given
fusionhost - www.fusionhost.co.uk
Leading British Cloud Web Hosting Provider

DeLeTe Me

I found a negative side of doing this after-login hook.

When a customer is ordering without being logged in, and then tries to login in the order process, the customer still gets redirected to the clientarea, and not back to /cart.

And i don't like the constant "Cart" link in my menu.

BRJP

Quote from: ZeicoDK on August 31, 2014, 09:32:47 AM
When a customer is ordering without being logged in, and then tries to login in the order process, the customer still gets redirected to the clientarea, and not back to /cart.

I was coming to the same conclusion that this would be the case.  Now you have confirmed this, I am not keen to fix one issue and cause another.  What I am after is a redirect to Clientarea explicitly if you log in afresh.

So we are back to square one on this mystery - how do make this change for fresh logins that does not affect logins during the product/service sign-up process.
Kind regards,
Bradley Porter
--------------------
Find out more about SaneChoice Services at: https://www.sanechoice.cloud/

BRJP

Anyone had any further thoughts on how you redirect logins to the Dashboard?  (Without impacting other login designations within order process).

This is a hard one to crack for something that is so simple in principal!
Kind regards,
Bradley Porter
--------------------
Find out more about SaneChoice Services at: https://www.sanechoice.cloud/

craggy

BJRP did you ever figure this out?

We are facing the same issue at the moment.

BRJP

We are still battling with this one! 

To be honest, we dropped the focus on this as we have plenty of other work on but we still want to be able to achieve this.
Kind regards,
Bradley Porter
--------------------
Find out more about SaneChoice Services at: https://www.sanechoice.cloud/

craggy

Ok, not sure if this works for you but I just threw this together and it works perfectly for our situation,

Why not just replace the content of root.tpl with this:

{if $logged=='1'}
{include file='clientarea/dashboard.tpl'}
{else}
{include file='login.tpl'}
{/if}