<p>There is a <code>currentUser</code> global variable that is available to all Twig templates.</p>

<p>If there is a currently logged in user, it will return that user's <a href="https://craftcms.com/docs/templating/craft.users" rel="nofollow noreferrer">UserModel</a> class.</p>

<p>From there, it's just a matter of:</p>

<pre><code>{% if currentUser %}
    form=http://formsite.com/formname?email={{ currentUser.email }}
{% endif %}
</code></pre>

<p>Of course, what's inside the <code>if</code> block will look different depending on how you're generating the embedded code URL.</p>

CC BY-SA 3.0
2018-01-11T18:24:33.690Z
Thank you Brad. I did a bit more digging to figure out all that I needed to do. I created a new matrix field / block , created the html page for it (using your example) and, Voila! I'll be able to build on this.
Jon
CC BY-SA 3.0
2018-01-08T22:09:52.853Z
2018-01-08T22:09:52.853Z
Brad Bell
<p>I need to pass the logged-in user's <em>email address</em> as a variable to a embedded javascript form. I think the easiest way for me to do this is to dynamically embed the user's email address in the embed code URL.</p>

<p>Within the javascript snippet in the HTML block would be a URL "form=<a href="http://www.formsite.com/formname?email=" rel="nofollow noreferrer">http://www.formsite.com/formname?email=</a><strong>XXXX@XXX.COM</strong>" -- how can I pass the logged in user's email into that?</p>

<p>I'm not a web developer nor do I have a lot of experience with craft other than as an admin level user. I'm trying to accomplish this without enlisting the services of a web developer to do any custom work.</p>

CC BY-SA 3.0
2018-01-08T17:50:38.897Z
Have you looked into accessing the `UserModel`? https://craftcms.com/docs/templating/craft.users
Mark Busnelli Jr
<templating><entries><current-user><blocks>
Include user information in html block
# Include user information in html block

(Asked by: username_0 on 2018-01-08)

I need to pass the logged-in user's *email address* as a variable to a embedded javascript form. I think the easiest way for me to do this is to dynamically embed the user's email address in the embed code URL.

Within the javascript snippet in the HTML block would be a URL "form=<http://www.formsite.com/formname?email=>**XXXX@XXX.COM**" -- how can I pass the logged in user's email into that?

I'm not a web developer nor do I have a lot of experience with craft other than as an admin level user. I'm trying to accomplish this without enlisting the services of a web developer to do any custom work.

**Tags:** templating, entries, current-user, blocks

> **Comments:**
> **username_1**: Have you looked into accessing the `UserModel`? https://craftcms.com/docs/templating/craft.users  

---

## 1 answers

### Answer by username_2 on 2018-01-08. Score: 1 | Accepted answer

There is a currentUser global variable that is available to all Twig templates.
If there is a currently logged in user, it will return that user's UserModel class.
From there, it's just a matter of:
{% if currentUser %}
    form=http://formsite.com/formname?email={{ currentUser.email }}
{% endif %}

Of course, what's inside the if block will look different depending on how you're generating the embedded code URL.

> **Comments:**
> **username_0**: Thank you Brad. I did a bit more digging to figure out all that I needed to do. I created a new matrix field / block , created the html page for it (using your example) and, Voila! I'll be able to build on this.  

---

