1

See below updates and accepted answer for a full solution

I finally discovered postCpLoginRedirect which solves my needs, even though I only need users to access their profile (which includes lots of custom fields, hopefully we'll have a few more permissions options in future for the cp).

Anyway, the issue I'm having is I want to redirect to a front-end dashboard which is at {{siteUrl}}counsellors/dashboard. This page has a {% requireLogin %} tag which redirects to the cpTrigger. And, as cp is enabled for default user groups, I understand activateAccountSuccessPath, postLoginRedirect are defunct settings.

  • When logging in from the Craft cpTrigger the relative link string /counsellors/dashboard works fine.
  • But when used in combination with the autoLoginAfterAccountActivation it directs to the wrong path (relative to the admin trigger login/counsellors/dashboard)

Ideally I'd like to keep it separate as eventually the CP will be swapped out for a front-end solution, so any clues as to why this is happening? Or what combination of settings are required to fix it?

settings:

'cpTrigger' => 'login',
'postCpLoginRedirect' => '/counsellors/dashboard',
'activateAccountSuccessPath' => '/counsellors/dashboard',
'autoLoginAfterAccountActivation' => true,
'loginPath' => 'login' # Redirect to cp trigger
// 'postLoginRedirect' => 'counsellors/dashboard',

Updates 28/01/2016:

If you're giving users access to Control Panel activateAccountSuccessPath won't work, regardless of the patha plugin is required to make this happen.

So it seems for now at least, everything has to be built front-end as @RitterKnight suggests

  • A big caveat is, no matter what, if a new registered user has access to the CP, activateAccountSuccessPath is ignored. You'll need a plugin to have newly activated accounts forwarded to your success page.
  • Another nice addition is to use the brilliant Control Panel Nav plugin (which really I think should be built into Craft)
    • If you're having users login directly from CP login, you can couple this with postCpLoginRedirect if you want to hide the dashboard from users.

So to recap, full settings are now:

  1. Front end registration, front-end success page, front-end login form, front-end dashboard;

  2. A plugin to enforce activateAccountSuccessPath settings

  3. Control Panel Nav plugin with a link to the custom dashboard;

  4. The following config settings:

'loginPath' => 'counsellors/login', 'activateAccountSuccessPath' => 'counsellors/success', // 'autoLoginAfterAccountActivation' => true, # Doesn't work // 'postCpLoginRedirect' => 'myaccount#profile', # Optional 'postLoginRedirect' => 'counsellors/dashboard',

  • So you're using the CP for users to edit their profiles but everything else is on the front end? – RitterKnight Jan 13 '16 at 23:52
  • @RitterKnight Thanks for the answer. I was hoping I could avoid creating a front-end form for now, the custom front-end is just a dashboard for onboarding (planning to expand it out later). All user interaction is through CP profile editing. Idea was to use regular cpTrigger for all logins, but redirect them to the dashboard as a starting point — which seems like it should be possible, but perhaps not! So loginPath is intentionally redirecting {% requireLogin %} to standard login, works as expected. autoLoginAfterAccountActivation` doesn't seem to play nice with postCpLoginRedirect :( – Rob Jan 14 '16 at 2:40
2

Ideally I'd like to keep it separate as eventually the CP will be swapped out for a front-end solution, so any clues as to why this is happening?

I think you're close. Just so we're on the same plane, you're using the CP for users to edit their profiles but everything else is on the front end? Do you have a front end login form already setup? If not, get one setup at counsellors/login.

Don't set your cpTrigger and loginPath to the same values if you intend to keep the front and back end logins separate to begin with. That's issue number 1.

On the front end, you probably want to set loginPath to something like counsellors/login and you'll want to obviously uncomment your postLoginRedirect to counsellors/dashboard so after they login, they'll get shuttled off to that page.

Set activateAccountSuccessPath to something like something like members/activation-success and then in that template, you can do whatever you want there, either link back to the CP with a hyperlink so users can "finish" their profiles or use Craft's {% redirect %} code to send them to the CP.

  • Thanks for this, marking as the accepted answer. Although, it does seem overkill for a simple custom dashboard/onboarding page — I'll submit a bug report to P+T and see if it's expected behaviour (the redirect). – Rob Jan 14 '16 at 18:10
  • You might want to start a new question or email P&T directly. You could create the user without CP privileges and then add them on at some point down the line but that seems overkill in your case since editing a profile on the front end is straightforward enough. – RitterKnight Jan 27 '16 at 18:39
  • Yeah sorry that question was a bit premature (I've deleted it now). I've sent them two support requests but heard nothing in 2 weeks, I imagine their flooded with requests. Front-end profile editing is in the backlog as they haven't the budget — a potential workaround is Control Panel Nav plugin, where at least I can remove dashboard and add a link to our own. Not ideal, but only option to avoid signup confusion. – Rob Jan 27 '16 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.