Answers.Body: <p>It depends on which message template you are trying to add token to and method you are using for sending email. </p>
  
  <p>Not all method of sending email renders membership token. If you are successful to render {membership.id} or if you can get membership from smarty then you can use CiviCRM api to render the custom field value for membership based on membership id. </p>
  
  <p>For ref: <a href="https://civicrm.stackexchange.com/questions/29230/how-to-create-tokens-for-custom-fields-participant-individual-organisation/29232#29232">How to create tokens for custom fields (participant, individual, organisation)</a></p>
  
  <p>HTH</p>
  
  <p>Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-19T15:35:03.263Z
Answers.Text: Thank you Pradeep,
Answers.UserDisplayName: Benn54
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-19T15:47:43.493Z
Answers.Text: Thank you Pradeep, I am using existing tokens that are created by the Fuzion Tokens exttension. These are redered okay. But the tokens for the created custom fields are not in this extension. I am sending email via smtp. When i put a {debug} in the message template i get an email with a lot of data but no custom id or anything like that. The example with the api is far too complex for me. Sorry.
Answers.UserDisplayName: Benn54
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-19T12:36:21.883Z
Answers.LastActivityDate: 2019-12-19T12:36:21.883Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I created a custom field set and a custom field used for memberships.
  Now i would like to insert the data from the custom field into my e-mail template.
  So i tried to find the custom field id by going to the edit custom field page: </p>
  
  <pre><code>?option=com_civicrm&amp;task=civicrm/admin/custom/group/field&amp;reset=1&amp;action=browse&amp;gid=4
  </code></pre>
  
  <p>So i presume that the the id is membership.custom_4 (???)
  However when i add another Custom Field in the same group, I also find the same id. So it looks like the id that i find is from the Custom Field Set.</p>
  
  <p>My question/problem is: what is the correct way to find out the custom field id and what is the correct syntax for this membership custom field within Smarty</p>
  
  <p>When using the following code in the e-mail, the mail is not sent and the interface hangs forever. I only use plain text e-mail for testing.</p>
  
  <pre><code>{capture assign=lic}{membership.custom_4}{/capture}
  {$lic}
  </code></pre>
  
Tags: <civimember><custom-fields><smarty>
Title: Unable to insert membership custom field in e-mail using Smarty
ThreadText: # Unable to insert membership custom field in e-mail using Smarty
  
  (Asked by: username_0 on 2019-12-19)
  
  I created a custom field set and a custom field used for memberships.
  Now i would like to insert the data from the custom field into my e-mail template.
  So i tried to find the custom field id by going to the edit custom field page: 
  ?option=com_civicrm&task=civicrm/admin/custom/group/field&reset=1&action=browse&gid=4
  
  So i presume that the the id is membership.custom_4 (???)
  However when i add another Custom Field in the same group, I also find the same id. So it looks like the id that i find is from the Custom Field Set.
  My question/problem is: what is the correct way to find out the custom field id and what is the correct syntax for this membership custom field within Smarty
  When using the following code in the e-mail, the mail is not sent and the interface hangs forever. I only use plain text e-mail for testing.
  {capture assign=lic}{membership.custom_4}{/capture}
  {$lic}
  
  **Tags:** civimember, custom-fields, smarty
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-12-19. Score: 1
  
  It depends on which message template you are trying to add token to and method you are using for sending email.
  
  Not all method of sending email renders membership token. If you are successful to render {membership.id} or if you can get membership from smarty then you can use CiviCRM api to render the custom field value for membership based on membership id.
  
  For ref: [How to create tokens for custom fields (participant, individual, organisation)](https://civicrm.stackexchange.com/questions/29230/how-to-create-tokens-for-custom-fields-participant-individual-organisation/29232#29232)
  
  HTH
  
  Pradeep
  
  > **Comments:**
  > **username_0**: Thank you Pradeep,  
  > **username_0**: Thank you Pradeep, I am using existing tokens that are created by the Fuzion Tokens exttension. These are redered okay. But the tokens for the created custom fields are not in this extension. I am sending email via smtp. When i put a {debug} in the message template i get an email with a lot of data but no custom id or anything like that. The example with the api is far too complex for me. Sorry.  
  
  ---
  
  