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

Token replacement issues in membership reminder email

    Details

      Description

      Some tokens are replaced with blank values in the membership email reminders automatically sent via the Job scheduler, while some others are replaced fine. This happens at least with the standard

      {contact.email_greeting}

      token, as well as with all tokens defined via the hook system. When an email is sent as an activity to the same contact(s), using the same template as the email reminder all token replacements are done perfectly.

      I noticed the token replacement code seem very different in both cases:

      • the token replacements for email reminders is done in the CRM_Core_BAO_MessageTemplates::sendReminder function
      • it uses CRM_Mailing_BAO_Mailing::getTokens to identify tokens to be replaced
      • it replaces the token values from a call to CRM_Contact_BAO_Query::apiQuery
      • the token replacements for emails sent as activities is done in the CRM_Activity_BAO_Activity::sendEmail function
      • it uses CRM_Utils_Token::getTokens to identify tokens to be replaced
      • it replaces the token values from a call to CRM_Utils_Token::getTokenDetails

      I therefore recreated the token identification and replacement code in the CRM_Core_BAO_MessageTemplates::sendReminder using the code from CRM_Activity_BAO_Activity::sendEmail. I tested it with both standard tokens and tokens defined via the hook system and it works perfectly now - all tokens are replaced with the correct values.

      Attached is the corresponding patch for file CRM/Core/BAO/MessageTemplates.php

        Attachments

        1. MessageTemplates.patch
          2 kB
          Nicolas Ganivet
        2. MessageTemplates.php.patch
          4 kB
          Nicolas Ganivet
        3. MessageTemplates.php.v2.patch
          5 kB
          Nicolas Ganivet

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              nganivet Nicolas Ganivet
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 15 minutes
                15m
                Remaining:
                Remaining Estimate - 15 minutes
                15m
                Logged:
                Time Spent - Not Specified
                Not Specified