Answers.Body: <p>The above template path code works fine. I was just looking for a user variable that hadn't yet been set</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-26T12:29:49.260Z
Answers.LastActivityDate: 2017-04-26T12:29:49.260Z
Answers.UserDisplayName: joomkit
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-25T22:34:40.710Z
Comments.Text: Weird/flaky this is a real blocker now. I can get other profile fields with user.myfield but not the one i want.....
Comments.UserDisplayName: joomkit
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-25T22:37:59.120Z
Comments.Text: Solved: had changed the user object variable so that one field was empty. Fine now. Phew
Comments.UserDisplayName: joomkit
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-26T06:31:29.773Z
Comments.Text: Can you please post an official answer, or close the question?
Comments.UserDisplayName: carlcs
Tags: <plugin-development><emails><registration>
Title: Email template variables not rendering from plugin
ThreadText: # 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
  
  
  ---
  
  