Answers.Body: <p>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 <em>sometimes</em>. 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.</p>
  <p>Put in a file somewhere and run with <code>cv scr filename.php</code></p>
  <pre><code>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-&gt;fetch()) {
        $templates[] = ['name' =&gt; $dao-&gt;workflow_name, 'type' =&gt; 'subject'];
        $templates[] = ['name' =&gt; $dao-&gt;workflow_name, 'type' =&gt; 'text'];
        $templates[] = ['name' =&gt; $dao-&gt;workflow_name, 'type' =&gt; 'html'];
      }
      return $templates;
    }
  }
  
  (new ReplaceMessageTemplates('dontcare'))-&gt;updateTemplates();
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-11-14T09:47:51.670Z
Answers.Text: "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.
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-11-14T09:57:31.920Z
Answers.Text: 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.
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-11-14T15:35:14.387Z
Answers.Text: What happens if you delete the html temporarily too? Do you still get the message?
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-12-19T11:12:53.370Z
Answers.Text: Is there a way to do this without cv? I'm running on shared hosting and can't install my own utilities like CV.
Answers.UserDisplayName: Tim Vaughan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-12-19T14:51:39.933Z
Answers.Text: I suppose you could put the code into an extension, similar to how https://github.com/agh1/com.aghstrategies.uscounties/blob/main/uscounties.php does its thing automatically after you install it, and then you just uninstall it after.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-10-25T13:37:58.380Z
Answers.LastActivityDate: 2024-10-25T13:37:58.380Z
Answers.UserDisplayName: Demerit
Answers.Body: <p>To review the email template changes, go to CiviCRM &gt;&gt; Mailings &gt;&gt; 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.</p>
  <p>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.</p>
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-10-25T11:23:08.933Z
Answers.Text: 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)?
Answers.UserDisplayName: Aivars
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-10-25T10:03:07.593Z
Answers.LastActivityDate: 2024-10-25T10:03:07.593Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>CiviCRM System Status shows that there are <strong>outdated tokens</strong> in use in <em>membership_online_receipt</em> and <em>event_online_receipt</em> message templates.</p>
  <p>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).</p>
  <p><strong>How can I replace these templates with current default ones?</strong></p>
  <p>Drupal 10, CiviCRM 5.78.3</p>
  <p><a href="https://i.sstatic.net/e8KHmU6v.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/e8KHmU6v.png" alt="enter image description here" /></a></p>
  
Tags: <message-templates>
Title: How to overwrite message templates with default ones?
ThreadText: # How to overwrite message templates with default ones?
  
  (Asked by: username_0 on 2024-10-25)
  
  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](https://i.sstatic.net/e8KHmU6v.png)](https://i.sstatic.net/e8KHmU6v.png)
  
  **Tags:** message-templates
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2024-10-25. Score: 2 | Accepted answer
  
  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();
  
  > **Comments:**
  > **username_2**: "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.  
  > **username_2**: 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.  
  > **username_1**: What happens if you delete the html temporarily too? Do you still get the message?  
  > **username_3**: Is there a way to do this without cv? I'm running on shared hosting and can't install my own utilities like CV.  
  > **username_1**: I suppose you could put the code into an extension, similar to how https://github.com/agh1/com.aghstrategies.uscounties/blob/main/uscounties.php does its thing automatically after you install it, and then you just uninstall it after.  
  
  ---
  
  ### Answer by username_4 on 2024-10-25. Score: 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.
  
  > **Comments:**
  > **username_0**: 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)?  
  
  ---
  
  