2

CiviCRM System Status shows that there are outdated tokens in use in membership_online_receipt and event_online_receipt message templates.

I have never customized these templates, so, in my understanding, they had to be overwritten with new ones during upgrade. It seems not to have happened (assuming that the new CiviCRM versions do not come with outdated tokens).

How can I replace these templates with current default ones?

Drupal 10, CiviCRM 5.78.3

enter image description here

2 Answers 2

2

Pradeep's answer is right if the database default matches the on-disk version, but the civi upgrade process only refreshes the database default from the on-disk version sometimes. I've used the below script before to unconditionally update all the defaults in the database from the disk. I can't remember offhand if it also wipes all your customizations - I don't think so, but make a backup first of the civicrm_msg_template table, although it sounds like you actually do want to reset and update everything anyway.

Put in a file somewhere and run with cv scr filename.php

class ReplaceMessageTemplates extends \CRM_Upgrade_Incremental_MessageTemplates {
  /**
   * Override
   */
  public function getTemplatesToUpdate() {
    $templates = [];
    $dao = CRM_Core_DAO::executeQuery('SELECT workflow_name FROM civicrm_msg_template WHERE workflow_name IS NOT NULL GROUP BY workflow_name');
    while ($dao->fetch()) {
      $templates[] = ['name' => $dao->workflow_name, 'type' => 'subject'];
      $templates[] = ['name' => $dao->workflow_name, 'type' => 'text'];
      $templates[] = ['name' => $dao->workflow_name, 'type' => 'html'];
    }
    return $templates;
  }
}

(new ReplaceMessageTemplates('dontcare'))->updateTemplates();
3
  • "the civi upgrade process only refreshes the database default from the on-disk version sometimes"? What's that about then? Like Alvars above, I've just upgraded a site to 5.79 and it's whining about deprecated tokens when all my templates are the defaults.
    – Graham
    Commented Nov 14 at 9:47
  • After running the above script, clearing caches, and re-chicking to ensure that all System Workflow Messages are set to the default, I'm still seeing the warning about outdated tokens in membership_online_receipt. Indeed they are there in the plain text content. But even if I delete all of the plain text template content the waring persists.
    – Graham
    Commented Nov 14 at 9:57
  • What happens if you delete the html temporarily too? Do you still get the message?
    – Demerit
    Commented Nov 14 at 15:35
1

To review the email template changes, go to CiviCRM >> Mailings >> Message Templates, click on the System Workflow Messages tab, and locate the template titled 'Memberships - Receipt (on-line)'. You should see options to Edit, Revert, and View Default.

These three options appear because the template has been overridden. You can compare it with the default version to see if there are any changes specific to your website. If you don't notice any significant changes, you can click Revert to restore the default.

In most cases, the typical customizations we’ve seen include adding a logo to the receipt or updating organization details like the address. After reverting, these modifications can easily be reapplied if needed.

1
  • Thank you, Pradeep! I did this even before. When I change something, there appears an option to restore default. I did that, too. So I am assuming, I have a non-customized default template which still generates these warnings. And this default template does contain mentioned outdated tokens. I am assuming that current CiviCRM installations do not have these outdated tokens in templates. So I wonder, what has gone wrong in my case and how to move to current default template (rather than some possibly outdated default template)?
    – Aivars
    Commented Oct 25 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.