I have created an entry that requires users to be logged into to see it. This was just a minor request from our client and we didn't want to spend a lot of time setting up login forms etc.

Therefore I have just added {% requireLogin %} to the top of the entry's Twig file. This works great, so far so good.

The problem comes however when a user visits the URL for that page:


They are re-directed to the Craft login, as expected, but once they successfully login, instead of being re-directed back to the page, they are instead taken to the Craft admin dashboard, with the pages' slug at the end. So:


Can anyone shed some light as to what is going on here? How can I make it so once users are loged in, they are re-directed back to the page? I've seen Craft has a postLoginRedirect config, but I'm guessing this can't be set on a per-page basis.

  • Have you tried this with a non CP account? I believe any account with CP access automatically gets redirected to the control panel, so this would only work for user accounts that don't have that level of access.
    – Peter Tell
    Feb 11, 2015 at 13:52
  • @PeterTell Thanks Peter, but unfortunately that would not work in this instance. Our client has CP access so they can make content changes, but they want to be the only people who want to see this page.
    – Jamie Wade
    Feb 11, 2015 at 13:55

1 Answer 1


As far as I understand it, the postLoginRedirect only affects login forms defined on the the front-end. If a user visits the login page (through a 'login' link for example), then they will be redirected to 'postLoginRedirect' after logging in. They will also be redirected there if they attempt to visit the login form directly when already logged in.

Your best option is to just create a quick login page template, like the one provided in the docs. Craft will automatically look for 'login.html' in your templates folder - otherwise you can specify the location using the loginPath config setting.

With that defined, if a user tries to visit any page that has {{ loginRequired }} specified, they will automatically get redirected to the login page and subsequently be redirected back to the original page request after login.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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