Answers.Body: <p>I filed an issue and kind of half-fixed it so that <code>{customkey.tokenname}</code> shaped tokens should work. If my approach is valid this may also fix <a href="https://civicrm.stackexchange.com/questions/2004/error-for-token-php-related-to-greeting-tokens?rq=1">Error for token.php related to greeting tokens</a></p>
  
  <p>My issue: <a href="https://issues.civicrm.org/jira/browse/CRM-17038" rel="nofollow noreferrer">https://issues.civicrm.org/jira/browse/CRM-17038</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-19T20:10:01.387Z
Answers.Text: Fix is being updated and handles tokens in contact category like `{contact.tokenname}` as well now.
Answers.UserDisplayName: nielo
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-18T11:42:51.140Z
Answers.LastActivityDate: 2015-08-19T20:10:40.220Z
Answers.LastEditDate: 2017-04-13T12:53:13.167Z
Answers.UserDisplayName: nielo
Answers.Body: <p>It sounds like the hook isn't being called (or not called correctly) when processing the update_greeting job. I think that qualifies as a bug and you could file it in issues.civicrm.org. But due to the high volume of issues, a core team member may not be available to jump on it anytime soon. I'd suggest you keep on with your debugging and compare the code that runs during that scheduled job to the code that correctly uses the hook and see how they differ. If you are able to come up with a patch that even partially addresses the problem it would help the issue get a lot more attention (issues with patches get bumped up in priority).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-17T21:47:35.303Z
Answers.LastActivityDate: 2015-08-17T21:47:35.303Z
Answers.UserDisplayName: Coleman
Body: <p>I implemented miscellaneous custom tokens and have been using them successfully in mailings and pdf generation. </p>
  
  <p>But in context of greetings I came across some weird misbehaviour. I tested by changing email greeting and running api job.update_greeting w/ force=1.</p>
  
  <ol>
  <li>When extending the token array's "contact" key with a custom token, the {contact.tokenname} markup get's interpreted but not replaced. Result is '{contact.tokenname}'.</li>
  <li>When using custom key the markup {keyname.tokenname} is not recognized and even doesn't get into the hook function's token parameter. Result is '' and Smarty reports »unrecognized tag«.</li>
  </ol>
  
  <p>Both tokens run fine in pdf generation.</p>
  
  <p>I'm running latest Drupal 7 and CiviCRM.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks in advance</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-13T06:26:32.497Z
Comments.Text: Dear civi folks, 
  am I missing something? Is this a dumb question?
Comments.UserDisplayName: nielo
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-17T13:31:48.833Z
Comments.Text: Today I investigated a bit and it seems that Tokens.php won't handle {contact.tokenname} because it doesn't get into it's self::$_tokens array.
  And {keyname.tokenname} won't get to replaceHookTokens because it's keyname is different to »contact«. Any ideas how to come around this?
Comments.UserDisplayName: nielo
Tags: <tokens>
Title: Tokens in greetings not replaced
ThreadText: # Tokens in greetings not replaced
  
  (Asked by: username_0 on 2015-07-17)
  
  I implemented miscellaneous custom tokens and have been using them successfully in mailings and pdf generation.
  
  But in context of greetings I came across some weird misbehaviour. I tested by changing email greeting and running api job.update\_greeting w/ force=1.
  
  1. When extending the token array's "contact" key with a custom token, the {contact.tokenname} markup get's interpreted but not replaced. Result is '{contact.tokenname}'.
  2. When using custom key the markup {keyname.tokenname} is not recognized and even doesn't get into the hook function's token parameter. Result is '' and Smarty reports »unrecognized tag«.
  
  Both tokens run fine in pdf generation.
  
  I'm running latest Drupal 7 and CiviCRM.
  
  Any ideas?
  
  Thanks in advance
  
  **Tags:** tokens
  
  > **Comments:**
  > **username_0**: Dear civi folks,  am I missing something? Is this a dumb question?  
  > **username_0**: Today I investigated a bit and it seems that Tokens.php won't handle {contact.tokenname} because it doesn't get into it's self::$_tokens array. And {keyname.tokenname} won't get to replaceHookTokens because it's keyname is different to »contact«. Any ideas how to come around this?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2015-08-18. Score: 2 | Accepted answer
  
  I filed an issue and kind of half-fixed it so that `{customkey.tokenname}` shaped tokens should work. If my approach is valid this may also fix [Error for token.php related to greeting tokens](https://civicrm.stackexchange.com/questions/2004/error-for-token-php-related-to-greeting-tokens?rq=1)
  
  My issue: <https://issues.civicrm.org/jira/browse/CRM-17038>
  
  > **Comments:**
  > **username_0**: Fix is being updated and handles tokens in contact category like `{contact.tokenname}` as well now.  
  
  ---
  
  ### Answer by username_1 on 2015-08-17. Score: 3
  
  It sounds like the hook isn't being called (or not called correctly) when processing the update\_greeting job. I think that qualifies as a bug and you could file it in issues.civicrm.org. But due to the high volume of issues, a core team member may not be available to jump on it anytime soon. I'd suggest you keep on with your debugging and compare the code that runs during that scheduled job to the code that correctly uses the hook and see how they differ. If you are able to come up with a patch that even partially addresses the problem it would help the issue get a lot more attention (issues with patches get bumped up in priority).
  
  
  ---
  
  