<p>You should be able to get the return url from craft. I just did a quick test and it seemed to carry over to a registration page from a log in page that happened due to a restricted page, so maybe try something like this in your registration template:</p>

<pre><code>{% set redirectUrl = (craft.session.getReturnUrl() ?: '/') %}

&lt;input type="hidden" name="redirect" value="{{ redirectUrl }}"&gt;
</code></pre>

<p>That way after they register they will be redirected to the restricted page, asked to log in and then craft should redirect them to the restricted page automatically.</p>

<p>Hope that helps!</p>

CC BY-SA 3.0
2015-06-16T17:39:49.513Z
Brilliant, it works! Thank you! (and sorry for the looooong response time)
Kirk Roberts
CC BY-SA 3.0
2015-05-28T09:55:25.200Z
2015-05-28T09:55:25.200Z
Alec Ritson
<p>That question will almost certainly need to be rewritten, but at the moment I don't have the language to write it well (sorry).</p>

<p>We have a restricted item (asset, in this case) that successfully triggers the login form and then redirects the viewer to the restricted item after login. </p>

<p>What about if the viewer is not registered yet? We have a working registration form set up and auto-activation enabled. How can the referring restricted item be passed from the login form to the registration form and then have that restricted item shown immediately after registering?</p>

<redirect><registration><login>
How to do "restricted page/asset"->login->register->"restricted page/asset"?
# How to do "restricted page/asset"->login->register->"restricted page/asset"?

(Asked by: username_0 on 2015-05-27)

That question will almost certainly need to be rewritten, but at the moment I don't have the language to write it well (sorry).

We have a restricted item (asset, in this case) that successfully triggers the login form and then redirects the viewer to the restricted item after login.

What about if the viewer is not registered yet? We have a working registration form set up and auto-activation enabled. How can the referring restricted item be passed from the login form to the registration form and then have that restricted item shown immediately after registering?

**Tags:** redirect, registration, login


---

## 1 answers

### Answer by username_1 on 2015-05-28. Score: 2 | Accepted answer

You should be able to get the return url from craft. I just did a quick test and it seemed to carry over to a registration page from a log in page that happened due to a restricted page, so maybe try something like this in your registration template:
{% set redirectUrl = (craft.session.getReturnUrl() ?: '/') %}



That way after they register they will be redirected to the restricted page, asked to log in and then craft should redirect them to the restricted page automatically.
Hope that helps!

> **Comments:**
> **username_0**: Brilliant, it works! Thank you! (and sorry for the looooong response time)  

---

