Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-7864

Missing values from tokenValues function affects custom hook implementation

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 3.3.3
    • Fix Version/s: 4.1.0
    • Component/s: CiviMail
    • Labels:
      None

      Description

      This is in reference to this blog post: http://civicrm.org/node/637

      Something appears to have changed in the code base for CiviMail through the course of development, causing the $values array to not carry the "first_name", "last_name" and "middle_name" values into the tokenValues function. When creating the custom hook as that blog post suggests, the hook "default" values will always replace the actual values, regardless of whether they are blank or not because these values are not present.

      Here is a dump of the $values array from that token hook at the beginning of the function:

      Array ( [1] => Array ( [contact_id] => 1 [display_name] => First Name Last Name [nick_name] => Nick Name [preferred_mail_format] => Both [is_deceased] => 0 [email_id] => 2 [on_hold] => 0 ) )

      Note that "nick_name" was set and thus it passed in the array, but "first_name", "last_name" and "middle_name" did not, even though they were present in the contact record. Not having the full set of values available through that variable renders token hooks less helpful in this scenario.

      If however, this is a known behavior, the blog post should be updated to reflect this change as right now it is misleading. Presumably, then, for it to function properly, it would require a database query to bring those values in for each contact_id. This might also be helpful to note in the documentation on this page:
      http://wiki.civicrm.org/confluence/display/CRMDOC33/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmtokenValues

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              bizzynate Nathan West
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: