<p>I may be missing something here, but you probably just want to remove the <code>postLoginRedirect</code> setting from the config?</p>
<p>You could also try adding <code>{{ redirectInput(craft.app.user.returnUrl) }}</code> to the form.</p>
<p><code>craft.app.user.returnUrl</code> should return the URL that triggered the login.</p>

CC BY-SA 4.0
2020-06-18T13:08:29.307Z
I tried that, but if it's removed the user is sent to the default post login URL.
Andrew
CC BY-SA 4.0
2020-06-18T13:38:35.573Z
Hi, have updated my answer with another option. `craft.app.user.returnUrl` should give you the url that you want to redirect to, so setting the ```{{ redirectInput() }}``` value to that should sent the user back to the page that triggered the login.
dmatthams
CC BY-SA 4.0
2020-06-19T14:10:28.630Z
Yes that's done it!
Andrew
CC BY-SA 4.0
2020-06-16T16:16:32.553Z
2020-06-18T13:37:22.793Z
2020-06-18T13:37:22.793Z
dmatthams
<p>According to the Craft docs {% requireLogin %} on a page should return the user to the same page after login. This doesn't work for me - the returned page is always the one set in 'postLoginRedirect'.</p>

<p>In the config file, I've got this setup:</p>

<pre><code>    'postLogoutRedirect' =&gt; 'members/logout',

    'postLoginRedirect' =&gt; 'members',

    'loginPath' =&gt; 'members/login'
</code></pre>

<p>What am I missing?</p>

<login><requirelogin>
{% requireLogin %} not returning to original page
# {% requireLogin %} not returning to original page

(Asked by: username_0 on 2020-06-16)

According to the Craft docs {% requireLogin %} on a page should return the user to the same page after login. This doesn't work for me - the returned page is always the one set in 'postLoginRedirect'.
In the config file, I've got this setup:
    'postLogoutRedirect' => 'members/logout',

    'postLoginRedirect' => 'members',

    'loginPath' => 'members/login'

What am I missing?

**Tags:** login, requirelogin

---

## 1 answers

### Answer by username_1 on 2020-06-16. Score: 4 | Accepted answer

I may be missing something here, but you probably just want to remove the `postLoginRedirect` setting from the config?

You could also try adding `{{ redirectInput(craft.app.user.returnUrl) }}` to the form.

`craft.app.user.returnUrl` should return the URL that triggered the login.

> **Comments:**
> **username_0**: I tried that, but if it's removed the user is sent to the default post login URL.  
> **username_1**: Hi, have updated my answer with another option. `craft.app.user.returnUrl` should give you the url that you want to redirect to, so setting the ```{{ redirectInput() }}``` value to that should sent the user back to the page that triggered the login.  
> **username_0**: Yes that's done it!  

---

