afrimax55105
afrimax55105

I have a site with a password protected client area created using the User plugin. Upon successful login, clients are redirected to the Client Dashboard without a problem.

The login page says

  • if no user logged in--> show login form
  • elseif user is logged--> show account info (name, password, etc.)

If the User successfully logs in, but then comes back to the login page (comes back the next day), they see the account info page with no way to get t to the Dashboard and the options therein. I want them redirected to the Portal Dashboard (just like they are if they just log in).

{% redirect %} would be perfect here, but that does not work in October. If I use the 'onstart return redirect' coding, it sends everyone to the Dashboard, meaning no one can login.

Is there a simple way to invoke a redirect in the context of the if/elseif statement? Using Twig would be so much easier than the php code.

any help is appreciated.

mjauvin
mjauvin

I don't have enough information, but you can override any component partial and tailor to your needs.

mjauvin
afrimax55105
afrimax55105

I have a site using the standard 'User' plugin to create a members area. Members go to the 'client-portal' page to access this area.

If the member is not logged in, they see the login form (I did customize the partial).

If the member successfully logs in, they are sent to the 'client-dashboard' page. No problem.

If, however, they come back to the site tomorrow and click on the 'client-portal' link, they do not see the dashboard. Instead, they see their account details.

{% if not user %} {% partial account ~ '::signin' %} {% else %} {% partial account ~ '::update' %} {% endif %}

Tomorrow, I need the client to get redirected to 'client-dashboard' just like they did when they logged in the first time. They cannot see the dashboard options.

I need something like: {% else %} {% redirect 'client-dashboard' %} {% endif %}

This is not a partials questions. This is a conditional redirect question.

Hope this is clearer. Thank you, MJauvin!

  • max
mjauvin
mjauvin

Your explanation is really nice, but you mostly repeat what you already said.

Can you specify which component you use on which page and what property is set for each component?

BennoThommo
BennoThommo

@afrimax55105 if this is for a CMS page, you could add some code to the "Code" PHP section that could do a redirect on the login page:

<?php
function onStart()
{
    $user = Auth::getUser();
    if ($user) {
        return Redirect::to('/client-dashboard');
    }
}
afrimax55105
afrimax55105

The 'client-portal' page is the one they login and is a regular CMS page. I am using the 'User' plugin, so the 'client-portal' uses the 'account' component is from the 'User' plugin, while the layout for the page uses the 'session' component from the 'User' plugin.

The 'Redirect to' property in 'account' is set to 'client-dashboard'. The 'Activation Code Param' parameter is set to 'code' and the 'Alias' parameter is set to 'account'.

afrimax55105
afrimax55105

BennoThommo, Thank you!

That worked perfectly!

I do wish, however, there was a twig function for the same, particularly since twig already offers the 'redirect' command.

I have seen portions of that same code in my research, but have not been able to get it to work properly. You have solved my, problem, however, and I appreciate it.

1-8 of 8