Answers.Body: <p>First - you don't need a template file. You can type the template right into the settings textarea like you already had, and like the other email twig templates do it. Then, in your service, you do:</p>
  
  <pre><code>$email-&gt;body = craft()-&gt;templates-&gt;renderString($settings-&gt;welcomeEmailMessage, ['firstName'=&gt;$firstName]);
  </code></pre>
  
  <p>The settings textarea then need to have something like:</p>
  
  <pre><code>Hello {{firstName}}, welcome!
  </code></pre>
  
  <p>And then you should be all set!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-16T09:16:53.100Z
Answers.Text: By using this method, you will also have all your variables like `{{ siteName }}` rendered aswell. So you only need to worry about the custom variables like `{{ link }}` and by passing a user model as `'user' => $user` you will have access to things like `{{ user.friendlyName }}` without having to specify them one by one
Answers.UserDisplayName: Alec Ritson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-16T17:17:58.137Z
Answers.Text: Thank you very much! I apologize though, you'll need to hold my hand just a bit more. I've updated my question to show what I have so far.
Answers.UserDisplayName: Damon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-17T11:11:03.347Z
Answers.Text: I updated my answer a little to hopefully make it a little clearer.
Answers.UserDisplayName: megatrond
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-15T17:22:49.070Z
Answers.LastActivityDate: 2015-07-17T05:48:40.957Z
Answers.LastEditDate: 2015-07-17T05:48:40.957Z
Answers.UserDisplayName: megatrond
Body: <p>I would like to use a "dynamic" variable (for lack of better words) in my plugin settings. I am sending whomever fills out my contact form a welcome email. I'd like to be able to include the persons name if I could.</p>
  
  <p>Here is my settings file:</p>
  
  <p><strong>_settings.html</strong></p>
  
  <pre><code>{{
  forms.textareaField({
      label:        "Welcome email Message"|t,
      id:           'welcomeEmailMessage',
      name:         'welcomeEmailMessage',
      instructions: "The email message that is sent to that the person who filled out the contact form."|t,
      value:        (settings.welcomeEmailMessage ? settings.welcomeEmailMessage : "Thank you {firstName} from {siteName}"|t({ siteName: craft.app.siteName })),
      errors:       settings.getErrors('welcomeEmailMessage')
      })
  }}
  </code></pre>
  
  <p>I know <code>{siteName}</code> is a variable that's available everywhere. <code>{firstName}</code> is the name of my form input that I'd like to somehow hook into.</p>
  
  <p>I have all of the information I need to send the email to the user - just not sure how to connect the dots between the service that sends the email and the settings so I can use <code>{firstName}</code> and it will get replaced with the value of the <code>firstName</code> input field.</p>
  
  <p>Here is my service if it helps to see what I'm trying to do...</p>
  
  <p><strong>MyService.php</strong></p>
  
  <pre><code>...
      $email-&gt;toEmail = $contact-&gt;email;
      $email-&gt;subject = $settings-&gt;guestSubject;
      $email-&gt;body = $settings-&gt;welcomeEmailMessage;
  ...
  </code></pre>
  
  <p><strong>EDIT</strong>
  Sorry, this is kind of hard to describe. I'll keep going maybe that will help.</p>
  
  <p>I have a contact form plugin, that has a setting of <code>welcomeEmailMessage</code>. That setting allows the admin to set the text to the email that is sent to whomever filled out my form. Think of it like a confirmation email.</p>
  
  <p>But, instead of just saying "Hi there..." I was trying to grab the value of the <code>firstName</code> input and inject that into the email message that resides in the plugin settings.</p>
  
  <p>The email could then read: "Hi there Bob..."</p>
  
  <p>I have attached a screen shot of my settings page.
  <img src="https://i.sstatic.net/7i3Pm.png" alt="enter image description here"></p>
  
  <p>So you can see in the image I have <code>{firstName}</code> in the textarea. I'm struggling on how to grab the value from the contact form - and inject it into that template variable.</p>
  
  <p>It looks like it's very similar to the "Email Settings" area within the CP. Only instead of getting the dynamic parts from the install settings, I want to get the values from the form that was submitted.</p>
  
  <p><img src="https://i.sstatic.net/wWzdi.png" alt="enter image description here"></p>
  
  <p>Hope that helps?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Reading though the comments, I'm struggling a little about how to implement them. </p>
  
  <p>Here is my <code>welcomeEmailMessage</code>. It's located in my plugin's directory/templates</p>
  
  <p><strong>html</strong></p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;div&gt;
              Hello, {{ firstName }}
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Then in my service I now have this:</p>
  
  <p><strong>php</strong></p>
  
  <pre><code>$email = new EmailModel();
  craft()-&gt;templates-&gt;renderString($settings-&gt;welcomeEmailMessage, ['firstName' =&gt; $contact-&gt;firstName]);
  </code></pre>
  
  <p>So now it seems like I need to tell my plugin how to get to that template?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-15T02:24:48.047Z
Comments.Text: Not sure I'm following... where is the person's name coming from?  The currently logged in user?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-15T15:07:47.063Z
Comments.Text: The person's name would come from the contact form. Once they click submit, I can grab the input value(s) but I'm not sure how to associate those values back to my plugin settings.
Comments.UserDisplayName: Damon
Tags: <plugin-development>
Title: How do I use dynamic variables for plugin settings?
ThreadText: # How do I use dynamic variables for plugin settings?
  
  (Asked by: username_0 on 2015-07-14)
  
  I would like to use a "dynamic" variable (for lack of better words) in my plugin settings. I am sending whomever fills out my contact form a welcome email. I'd like to be able to include the persons name if I could.
  
  Here is my settings file:
  
  **\_settings.html**
  
  ```
  {{
  forms.textareaField({
      label:        "Welcome email Message"|t,
      id:           'welcomeEmailMessage',
      name:         'welcomeEmailMessage',
      instructions: "The email message that is sent to that the person who filled out the contact form."|t,
      value:        (settings.welcomeEmailMessage ? settings.welcomeEmailMessage : "Thank you {firstName} from {siteName}"|t({ siteName: craft.app.siteName })),
      errors:       settings.getErrors('welcomeEmailMessage')
      })
  }}
  
  ```
  
  I know `{siteName}` is a variable that's available everywhere. `{firstName}` is the name of my form input that I'd like to somehow hook into.
  
  I have all of the information I need to send the email to the user - just not sure how to connect the dots between the service that sends the email and the settings so I can use `{firstName}` and it will get replaced with the value of the `firstName` input field.
  
  Here is my service if it helps to see what I'm trying to do...
  
  **MyService.php**
  
  ```
  ...
      $email->toEmail = $contact->email;
      $email->subject = $settings->guestSubject;
      $email->body = $settings->welcomeEmailMessage;
  ...
  
  ```
  
  **EDIT**
  Sorry, this is kind of hard to describe. I'll keep going maybe that will help.
  
  I have a contact form plugin, that has a setting of `welcomeEmailMessage`. That setting allows the admin to set the text to the email that is sent to whomever filled out my form. Think of it like a confirmation email.
  
  But, instead of just saying "Hi there..." I was trying to grab the value of the `firstName` input and inject that into the email message that resides in the plugin settings.
  
  The email could then read: "Hi there Bob..."
  
  I have attached a screen shot of my settings page.
  ![enter image description here](https://i.sstatic.net/7i3Pm.png)
  
  So you can see in the image I have `{firstName}` in the textarea. I'm struggling on how to grab the value from the contact form - and inject it into that template variable.
  
  It looks like it's very similar to the "Email Settings" area within the CP. Only instead of getting the dynamic parts from the install settings, I want to get the values from the form that was submitted.
  
  ![enter image description here](https://i.sstatic.net/wWzdi.png)
  
  Hope that helps?
  
  **EDIT**
  
  Reading though the comments, I'm struggling a little about how to implement them.
  
  Here is my `welcomeEmailMessage`. It's located in my plugin's directory/templates
  
  **html**
  
  ```
  <html>
      <body>
          <div>
              Hello, {{ firstName }}
          </div>
      </body>
  </html>
  
  ```
  
  Then in my service I now have this:
  
  **php**
  
  ```
  $email = new EmailModel();
  craft()->templates->renderString($settings->welcomeEmailMessage, ['firstName' => $contact->firstName]);
  
  ```
  
  So now it seems like I need to tell my plugin how to get to that template?
  
  **Tags:** plugin-development
  
  > **Comments:**
  > **username_1**: Not sure I'm following... where is the person's name coming from?  The currently logged in user?  
  > **username_0**: The person's name would come from the contact form. Once they click submit, I can grab the input value(s) but I'm not sure how to associate those values back to my plugin settings.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-07-15. Score: 3 | Accepted answer
  
  First - you don't need a template file. You can type the template right into the settings textarea like you already had, and like the other email twig templates do it. Then, in your service, you do:
  
  ```
  $email->body = craft()->templates->renderString($settings->welcomeEmailMessage, ['firstName'=>$firstName]);
  
  ```
  
  The settings textarea then need to have something like:
  
  ```
  Hello {{firstName}}, welcome!
  
  ```
  
  And then you should be all set!
  
  > **Comments:**
  > **username_3**: By using this method, you will also have all your variables like `{{ siteName }}` rendered aswell. So you only need to worry about the custom variables like `{{ link }}` and by passing a user model as `'user' => $user` you will have access to things like `{{ user.friendlyName }}` without having to specify them one by one  
  > **username_0**: Thank you very much! I apologize though, you'll need to hold my hand just a bit more. I've updated my question to show what I have so far.  
  > **username_2**: I updated my answer a little to hopefully make it a little clearer.  
  
  ---
  
  