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) »
  • Custom hook tokens not working in CiviMail
Pages: 1 [2]

Author Topic: Custom hook tokens not working in CiviMail  (Read 4344 times)

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Custom hook tokens not working in CiviMail
November 15, 2012, 03:58:55 am
Hey guys,

Not all tokens are created equal :)

I was experiencing this problem on 4.2.6 in CiviMail with tokens that started with {contact.

If I changed them to start {alumni. then they worked. 

The tokens in the wiki start with another word like party or date http://wiki.civicrm.org/confluence/display/CRMDOC42/Hook+Reference#HookReference-hook_civicrm_tokens which i suspect is why lobo and others weren't experiencing the problem.

Not sure at the moment whether this is a useful function or a bug but since contact.* tokens worked in sms, pdf and send email I suspect the later.

Working this out was a fun + and a massive hair pulling out experience :)
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Micah Lee

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 4
  • CiviCRM version: 4.1.0
  • CMS version: Drupal 7
  • MySQL version: 5.1.49
  • PHP version: 5.3.3
Re: Custom hook tokens not working in CiviMail
February 04, 2013, 12:22:18 pm
It looks like this is still a bug in some cases. I'm having this same problem using Drupal 7 and CiviCRM 4.2.6. When I send a test mailing to an email address or a group my hook_civicrm_tokenValues gets called and fills in the values correctly, but when I send the mailing and the process_mailing cron job does the sending my hook_civicrm_tokenValues never even gets executed.

Also, my tokens don't start with "{contact.", so Michael's solution won't work for me.

However, I'm run another CiviCRM site where this works completely fine. I'm not sure what's different. Is it possible that the cron job that's sending the mailing isn't bootstrapping Drupal in the correct way, so that my custom module that implements these hooks isn't getting loaded, but it is loaded when I send a test mailing?

Micah Lee

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 4
  • CiviCRM version: 4.1.0
  • CMS version: Drupal 7
  • MySQL version: 5.1.49
  • PHP version: 5.3.3
Re: Custom hook tokens not working in CiviMail
February 04, 2013, 01:16:10 pm
Fixed it. It turns out that it wasn't working because the custom module that implemented the hooks wasn't getting loaded during each cron job call.

This bug was preventing it from getting loaded: http://issues.civicrm.org/jira/browse/CRM-11212
And applying this patch fixes the problem: http://issues.civicrm.org/jira/secure/attachment/18386/CRM_Utils_Hook_Drupal.patch

Thanks Lobo for helping on IRC!

idmacdonald

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 1
Re: Custom hook tokens not working in CiviMail
February 05, 2013, 06:29:31 am
On a CiviCRM 4.2.2 install that I administer, I still get this problem sometimes. However, it seems to be caused by a more general problem with custom fields that seems to be fixed by clearing CiviCRM's cache tables. Custom fields don't export correctly and custom field tokens don't work. However, a 'drush civicrm-clear-cache' does seem to solve the problem. I've put that drush command into crontab so that it runs once a day. So far that seems to have fixed it.

-Ian

Andrew Perry

  • I post occasionally
  • **
  • Posts: 98
  • Karma: 1
  • Building empowering tools that comply with rules
    • Community Builders Australia
  • CiviCRM version: 3.x, 4.x
  • CMS version: Joomla 1.0.x, 1.5.x -> Drupal 6.x, 7.x, WordPress
  • MySQL version: 5.1, 5.5, 5.6
  • PHP version: 5.2, 5.3, 5.4
Re: Custom hook tokens not working in CiviMail
July 07, 2014, 01:56:48 am
For others trying the above command without success, you might be looking for 'drush civicrm-cache-clear'
Community Builders Australia Pty Ltd
www.communitybuilders.com.au

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • Custom hook tokens not working in CiviMail

This forum was archived on 2017-11-26.