# Variables in User Invite Template

**URL:** <https://community.dreamfactory.com/t/variables-in-user-invite-template/793>\
**Category:** Users & Roles\
**Created:** [January 28, 2015, 3:48pm UTC](https://community.dreamfactory.com/t/variables-in-user-invite-template/793 "2015-01-28T15:48:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikkurtu](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/erikkurtu/32/212_2.png) [@erikkurtu](https://community.dreamfactory.com/u/erikkurtu)\
**Post date:** [January 28, 2015, 3:48pm UTC](https://community.dreamfactory.com/t/variables-in-user-invite-template/793/1 "2015-01-28T15:48:53Z")

</div>

I’m sending user invites from my front end (with the code below), and would like to pass a couple variables to the User Invite Template - email address and app name. Is this possible?

```
var emailBody = {
    "first_name":"Jo",
    "last_name":"Satriani",
    "email":"satriani@gmail.com",
    "confirmed":false,
    "is_active":true,
    "is_sys_admin":false,
    "role_id":1
};
$.ajax({
    beforeSend: function(request) {
        request.setRequestHeader("X-DREAMFACTORY-SESSION-TOKEN", sessionStorage.SESSION_TOKEN);
        request.setRequestHeader("X-DREAMFACTORY-APPLICATION-Name", "admin");
    },
    type: 'POST',
    url: 'http://myServer.cloudapp.net/rest/system/user?send_invite=true',
    data: JSON.stringify(emailBody),
    cache: false
});
```

---

<div class="post-metadata">

**Author:** ![toddappleton](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/toddappleton/32/159_2.png) [@toddappleton](https://community.dreamfactory.com/u/toddappleton)\
**Post date:** [January 29, 2015, 7:36pm UTC](https://community.dreamfactory.com/t/variables-in-user-invite-template/793/2 "2015-01-29T19:36:27Z")

</div>

The fields in the just-created user object can be referenced in the email template. See the default user invite template in the Config–\>Email templates section of the admin console.

```
Hi {first_name},...
```

---

<div class="post-metadata">

**Author:** ![erikkurtu](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/erikkurtu/32/212_2.png) [@erikkurtu](https://community.dreamfactory.com/u/erikkurtu)\
**Post date:** [January 29, 2015, 9:23pm UTC](https://community.dreamfactory.com/t/variables-in-user-invite-template/793/3 "2015-01-29T21:23:36Z")

</div>

Yes, this works for first\_name in the user invite, but when I include {email} in the same template it just prints “{email}” in the resulting email, even though I’m sending an email field and value in the object.

---

<div class="post-metadata">

**Author:** ![erikkurtu](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/erikkurtu/32/212_2.png) [@erikkurtu](https://community.dreamfactory.com/u/erikkurtu)\
**Post date:** [February 2, 2015, 4:57pm UTC](https://community.dreamfactory.com/t/variables-in-user-invite-template/793/4 "2015-02-02T16:57:53Z")

</div>

I still haven’t found a solution. To be clear, I’m not just using a normal email template - I want to send variables when I create a new user, which triggers the assigned invite template to be sent.

I looked a bit at /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/lib-php-common-platform/src/Resources/User/Register.php and tried a couple things to get the email address to be available in the invite template in the same way first\_name, confirm\_code, etc. are, but no luck so far.

Can anyone direct me on what to edit in order to allow printing the email address of the created user in the invite template?

Thanks!

---

<div class="post-metadata">

**Author:** ![toddappleton](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/toddappleton/32/159_2.png) [@toddappleton](https://community.dreamfactory.com/u/toddappleton)\
**Post date:** [February 2, 2015, 7:00pm UTC](https://community.dreamfactory.com/t/variables-in-user-invite-template/793/5 "2015-02-02T19:00:31Z")

</div>

See line 201 in vendor/dreamfactory/lib-php-common-platform/src/Resources/System/User.php

```
$_userFields = array( 'first_name', 'last_name', 'display_name', 'confirm_code' );

```

It only makes these fields available. You can add email to the list.

I have created a bug report to make this more flexible in the future.

---

<div class="post-metadata">

**Author:** ![erikkurtu](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/erikkurtu/32/212_2.png) [@erikkurtu](https://community.dreamfactory.com/u/erikkurtu)\
**Post date:** [February 2, 2015, 7:10pm UTC](https://community.dreamfactory.com/t/variables-in-user-invite-template/793/6 "2015-02-02T19:10:00Z")

</div>

Perfect, thanks Todd! I’ll work with the same file to see about adding additional custom variables, but the email address was the most important one.

---

<div class="post-metadata">

**Author:** ![hassen\_isa](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/hassen_isa/32/174_2.png) [@hassen\_isa](https://community.dreamfactory.com/u/hassen_isa)\
**Post date:** [April 11, 2015, 8:56pm UTC](https://community.dreamfactory.com/t/variables-in-user-invite-template/793/7 "2015-04-11T20:56:56Z")

</div>

You can also use the {to} variable, as I found out the hard way.

---

<div class="post-metadata">

**Author:** ![erikkurtu](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/erikkurtu/32/212_2.png) [@erikkurtu](https://community.dreamfactory.com/u/erikkurtu)\
**Post date:** [April 13, 2015, 2:47pm UTC](https://community.dreamfactory.com/t/variables-in-user-invite-template/793/8 "2015-04-13T14:47:00Z")

</div>

Thanks hassen\_isa. That’ll save me from having to update those php files each time I upgrade DF.

---

<div class="post-metadata">

**Author:** ![michaelnagy](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/michaelnagy/32/583_2.png) [@michaelnagy](https://community.dreamfactory.com/u/michaelnagy)\
**Post date:** [February 13, 2016, 7:00pm UTC](https://community.dreamfactory.com/t/variables-in-user-invite-template/793/9 "2016-02-13T19:00:39Z")

</div>

It would be really nice if I could find all kind of system variables the system supports in mail templates, I can’t find any mention of the {to} variable in the dreamfactory documentation for example.

The {to} variable is not mentioned here: [https://wiki.dreamfactory.com/DreamFactory/Features/Lookups](https://wiki.dreamfactory.com/DreamFactory/Features/Lookups)
