<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>

CC BY-SA 4.0
2024-10-22T17:47:44.547Z
I haven't seen it before but I'll try it.  Thank you!
mzg
CC BY-SA 4.0
2024-10-22T16:30:33.163Z
2024-10-22T16:30:33.163Z
Cole Henley
<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>

<login><redirect><authentication><requirelogin>
Redirecting to another page after a successful user log in
# 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  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 username_0?
Note:

You can customize where users should get redirected to after login via the 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,
Cole

> **Comments:**
> **username_0**: I haven't seen it before but I'll try it.  Thank you!  

---

