CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Stuck with hook_civicrm_tokenValues()
Pages: [1]

Author Topic: Stuck with hook_civicrm_tokenValues()  (Read 403 times)

roblog

  • I’m new here
  • *
  • Posts: 12
  • Karma: 0
  • CiviCRM version: 5.42
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Stuck with hook_civicrm_tokenValues()
April 25, 2016, 08:45:22 am
I'm trying to use hook_civicrm_tokenValues() with CiviMail on Drupal 7.

Within the hook, $max_amount is obtained from a database call, and I have the following code.
 
Code: [Select]
$x = 75.00;
var_dump($x);
$y = (double) $max_amount;
var_dump($y);
The output of this is: float(75) float(75), which is what I would expect. In other words, both $x and $y appear to be identical.

When I use $values[$cid]['myCustomToken.test'] = $x , the value 75 is passed as expected.

But when I use $values[$cid]['myCustomToken.test'] = $y, the value 0 is passed to the token?!

Please can someone tell me what I am doing wrong?
 



« Last Edit: April 25, 2016, 08:57:26 am by roblog »

roblog

  • I’m new here
  • *
  • Posts: 12
  • Karma: 0
  • CiviCRM version: 5.42
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Stuck with hook_civicrm_tokenValues()
April 27, 2016, 04:35:38 am
So I'm still stuck on this issue .. and its pretty perplexing. It seems its not an issue particular to the $max_amount variable, as I'm seeing the same problem with another variable now. The strange thing is, that most values are getting passed through to CiviMail OK, its just one or two that aren't.

I decided to dump some output into a file, and have learned that hook_civicrm_tokenValues() is used four times, when sending a test email, with the following values in $context:

CRM_Mailing_Form_Test
CRM_Mailing_BAO_MailingJob
CRM_Mailing_Form_Test
CRM_Mailing_Page_Preview

In three of these contexts all the values are correct, but in the MailingJob context, the values are wrong. In other words, when I expand 'Preview Mailing' in the CiviMail wizard, the mail content is correct, but the actual mail that I receive is not.

.. so I guess I need to investigate CRM_Mailing_BAO_MailingJob.

Any advice or tips would be appreciated!!
 
 

roblog

  • I’m new here
  • *
  • Posts: 12
  • Karma: 0
  • CiviCRM version: 5.42
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Stuck with hook_civicrm_tokenValues()
April 27, 2016, 04:36:43 am
By the way, I'm using CiviCRM 4.5.2

roblog

  • I’m new here
  • *
  • Posts: 12
  • Karma: 0
  • CiviCRM version: 5.42
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Stuck with hook_civicrm_tokenValues()
April 27, 2016, 04:50:00 am
OK .. another update if anybody is reading. I've just discovered that the issue only occurs with test mails. When I send the mail to scheduled jobs, it sends just fine. So I guess that's the issue closed for me, and I can get back on with my life :)

Hope my little monologue might be useful to someone else in the future!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Stuck with hook_civicrm_tokenValues()

This forum was archived on 2017-11-26.