Answers.Body: <p>Have you checked <a href="https://craftcms.com/knowledge-base/front-end-user-accounts" rel="nofollow noreferrer">this resource</a> mzg?</p>
  <p>Note:</p>
  <blockquote>
  <p>You can customize where users should get redirected to after login via the <a href="https://craftcms.com/docs/4.x/config/general.html#postloginredirect" rel="nofollow noreferrer">postLoginRedirect</a> config setting.</p>
  </blockquote>
  <p>Then for any pages or templates you want to password protect you would add the following:</p>
  <pre><code>{# Require that a user is logged in to view this form. #}
  {% requireLogin %}
  </code></pre>
  <p>Hope that helps,</p>
  <p>Cole</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-10-22T17:47:44.547Z
Answers.Text: I haven't seen it before but I'll try it.  Thank you!
Answers.UserDisplayName: mzg
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-10-22T16:30:33.163Z
Answers.LastActivityDate: 2024-10-22T16:30:33.163Z
Answers.UserDisplayName: Cole Henley
Body: <p>Subject: Assistance with User Authentication for Page Access</p>
  <p>Hi,</p>
  <p>I’m having trouble implementing a solution to restrict access to a page so that only authenticated users can view it. In my previous content management system, I used a .htaccess file to redirect users to a login page. Depending on their authentication status, they would then be redirected either to the intended page or receive a warning message and be sent back.</p>
  <p>I have a content page with <code>&lt;a href=&quot;&quot;&gt;</code> link to <code>/memberpage</code>, and I’d like users to be taken to the login page when they click it. If they authenticate successfully, they would be redirected to a different page; if not, they would see a warning message and return to the previous page.</p>
  <p>Could you please guide me on how to implement this?</p>
  <p>Thanks!
  J</p>
  
Tags: <login><redirect><authentication><requirelogin>
Title: Redirecting to another page after a successful user log in
ThreadText: # Redirecting to another page after a successful user log in
  
  (Asked by: username_0 on 2024-10-22)
  
  Subject: Assistance with User Authentication for Page Access
  
  Hi,
  
  I’m having trouble implementing a solution to restrict access to a page so that only authenticated users can view it. In my previous content management system, I used a .htaccess file to redirect users to a login page. Depending on their authentication status, they would then be redirected either to the intended page or receive a warning message and be sent back.
  
  I have a content page with `<a href="">` link to `/memberpage`, and I’d like users to be taken to the login page when they click it. If they authenticate successfully, they would be redirected to a different page; if not, they would see a warning message and return to the previous page.
  
  Could you please guide me on how to implement this?
  
  Thanks!
  J
  
  **Tags:** login, redirect, authentication, requirelogin
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-10-22. Score: 4
  
  Have you checked [this resource](https://craftcms.com/knowledge-base/front-end-user-accounts) mzg?
  
  Note:
  
  > You can customize where users should get redirected to after login via the [postLoginRedirect](https://craftcms.com/docs/4.x/config/general.html#postloginredirect) config setting.
  
  Then for any pages or templates you want to password protect you would add the following:
  
  ```
  {# Require that a user is logged in to view this form. #}
  {% requireLogin %}
  
  ```
  
  Hope that helps,
  
  username_1
  
  > **Comments:**
  > **username_0**: I haven't seen it before but I'll try it.  Thank you!  
  
  ---
  
  