<p>The above template path code works fine. I was just looking for a user variable that hadn't yet been set</p>

CC BY-SA 3.0
2017-04-26T12:29:49.260Z
2017-04-26T12:29:49.260Z
joomkit
<p>I am loading an email template for custom registration via a plugin.
I reset the template path and load my template like this:</p>

<pre><code>    $oldPath = craft()-&gt;path-&gt;getTemplatesPath();
    $newPath = craft()-&gt;path-&gt;getPluginsPath().'businesslogic/templates';
    craft()-&gt;path-&gt;setTemplatesPath($newPath);
    $bodyhtml = craft()-&gt;templates-&gt;render('emailreg.html', array(
        'user' =&gt; $user
    ));
</code></pre>

<p>In my html template ( an evil abomination of tables etc ) I am accessing the user variable {{user.firstname}} just fine. But the other variable $user->mycustomfield will not render - even though I can send it in the subject line, e.g.,</p>

<pre><code>$email-&gt;subject = 'New User Registration: ' . $user-&gt;firstName . ' ' . $user-&gt;registrationNumber;
</code></pre>

<p>So whats up here?</p>

CC BY-SA 3.0
2017-04-25T22:34:40.710Z
Weird/flaky this is a real blocker now. I can get other profile fields with user.myfield but not the one i want.....
joomkit
CC BY-SA 3.0
2017-04-25T22:37:59.120Z
Solved: had changed the user object variable so that one field was empty. Fine now. Phew
joomkit
CC BY-SA 3.0
2017-04-26T06:31:29.773Z
Can you please post an official answer, or close the question?
carlcs
<plugin-development><emails><registration>
Email template variables not rendering from plugin
# Email template variables not rendering from plugin

(Asked by: username_0 on 2017-04-25)

I am loading an email template for custom registration via a plugin.
I reset the template path and load my template like this:
    $oldPath = craft()->path->getTemplatesPath();
    $newPath = craft()->path->getPluginsPath().'businesslogic/templates';
    craft()->path->setTemplatesPath($newPath);
    $bodyhtml = craft()->templates->render('emailreg.html', array(
        'user' => $user
    ));

In my html template ( an evil abomination of tables etc ) I am accessing the user variable {{user.firstname}} just fine. But the other variable $user->mycustomfield will not render - even though I can send it in the subject line, e.g.,
$email->subject = 'New User Registration: ' . $user->firstName . ' ' . $user->registrationNumber;

So whats up here?

**Tags:** plugin-development, emails, registration
> **Comments:**
> **username_0**: Weird/flaky this is a real blocker now. I can get other profile fields with user.myfield but not the one i want.....  
> **username_0**: Solved: had changed the user object variable so that one field was empty. Fine now. Phew  
> **username_1**: Can you please post an official answer, or close the question?  

---

## 1 answers

### Answer by username_0 on 2017-04-26. Score: 1

The above template path code works fine. I was just looking for a user variable that hadn't yet been set


---

