Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-18T13:08:29.307Z
Answers.Text: I tried that, but if it's removed the user is sent to the default post login URL.
Answers.UserDisplayName: Andrew
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-18T13:38:35.573Z
Answers.Text: 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.
Answers.UserDisplayName: dmatthams
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-19T14:10:28.630Z
Answers.Text: Yes that's done it!
Answers.UserDisplayName: Andrew
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-16T16:16:32.553Z
Answers.LastActivityDate: 2020-06-18T13:37:22.793Z
Answers.LastEditDate: 2020-06-18T13:37:22.793Z
Answers.UserDisplayName: dmatthams
Body: <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>
  
Tags: <login><requirelogin>
Title: {% requireLogin %} not returning to original page
ThreadText: # {% 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!  
  
  ---
  
  