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) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • Tokens not appearing
Pages: [1]

Author Topic: Tokens not appearing  (Read 2766 times)

wnpc

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
Tokens not appearing
November 24, 2009, 03:14:11 am
Hi there,

I've created hooks to add in some membership data to the tokens that are available in mass emails.  This all seems to be working fine, and in fact the test email is coming out with the values in the appropriate locations in the email.  However when I send the actual email, there seems to be a problem and all the tokens defined in the hook are blank.  Can anyone point me in the right direction for fixing this as I don't seem to have found an answer in my searching

Thanks

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: Tokens not appearing
November 24, 2009, 03:33:42 am
hi,

If I understood correctly, you are using CiviMail w/ token hooks for your custom token replacement.
Also you are getting custom token values correctly inserted for test mail.

You might want to try to create a small group of contacts ( 2 - 3 ) and try to test custom token replacement for
a. Test Mailing. ( send Test mail to this group )
b. Actual Mailing.


kiran
« Last Edit: November 24, 2009, 03:41:33 am by kiran »
You Are Designed To Choose... Defined By Choice.

wnpc

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
Re: Tokens not appearing
November 24, 2009, 06:13:16 pm
Hi,

Done a little more testing as recommended and test mail is working fine to a group or an individual but not the real mailing.  I've also just run a test where the user/pass in the cron is the same as the user I'm usually logged in as and that still didn't work.  There's no apparent difference whether I run as a cron job or directly in http.

Any other ideas gratefully received

Cheers

« Last Edit: November 24, 2009, 10:51:57 pm by wnpc »

Marty

  • I post occasionally
  • **
  • Posts: 67
  • Karma: 14
    • Boulder County Arts Alliance
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.26
  • MySQL version: 5.5.37
  • PHP version: 5.4.27
Re: Tokens not appearing
December 15, 2009, 09:24:03 pm
I'm experiencing the same problem.  I verified that my civicrm_tokenValues() hook function gets called properly when sending direct email or printing PDF letters, but it never gets called when sending a mass mail via CiviMail.  It appears token replacement has been broken in CiviCRM 3.0.0.  This is a fairly big problem for me, so any help would be greatly appreciated!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Tokens not appearing
December 15, 2009, 09:32:37 pm
we discussed this problem, but forgot to update the forum topic. sorry about that.

here's the issue: the civimail cronjob is an standalone bin script that executes outside of drupal. As such it is unaware of all the other modules currently active. It does fire the token hook, BUT the module list is empty and hence no replacement is done

The solution to this is to bootstrap drupal in the civimail cronjob script (if it is the CMS that CiviCRM is operating under). Similar to the way we do it in the installer, we can reuse some of the below code:

Code: [Select]
                $cmsPath = 'Need to figure out how to get this path';
                chdir( $cmsPath );
                include_once "./includes/bootstrap.inc";
                drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

CiviCRM does not have the exact location where drupal is stored, so we'll need to address that issue. If you are using drupal multi-site, i suspect the above might get a wee bit more complicated (or not?)

if you can experiment with the above code and see what works for you that would be great. please update the forums once u've done so

thanx

lobo



« Last Edit: December 15, 2009, 09:36:30 pm by Donald Lobo »
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Marty

  • I post occasionally
  • **
  • Posts: 67
  • Karma: 14
    • Boulder County Arts Alliance
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.26
  • MySQL version: 5.5.37
  • PHP version: 5.4.27
Re: Tokens not appearing
December 16, 2009, 10:08:14 pm
Thanks Donald! Your solution makes perfect sense.  I added your code snippet to civimail.cronjob.php with $cmsPath = '../../../../..' to get back to my Drupal root.  I also added a chdir() back to the original dir after the call to bootstrap().

The only issue I encountered was a function name conflict, conf_init(), which is declared in both bootstrap.inc and civicrm.config.php.  To fix the problem, I renamed the function in civimail.config.php to civicrm_conf_init().

After making the changes, my tokenValues hook function now gets called properly during the CiviMail cron job processing and the token replacements work fine.

Thanks again for your help, and I'll hope to see a proper fix in an upcoming release.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Tokens not appearing
December 17, 2009, 06:56:37 am

would be great if you could package the below as a patch and make detection of the drupal "codebase" automatic. I think the code in conf_init will help a fair amount with that

if you do so, please file an issue along with a patch. this will be great and highly appreciated :)

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

danorton

  • I’m new here
  • *
  • Posts: 12
  • Karma: 0
Re: Tokens not appearing
May 15, 2010, 01:38:59 pm
Fixed in 3.2

http://issues.civicrm.org/jira/browse/CRM-4542

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • Tokens not appearing

This forum was archived on 2017-11-26.