Custom tokens not working in Scheduled Reminders
Overview
Custom tokens are not evaluated for Scheduled Reminders when initiated by Cron Job. The tokens are evaluated properly when the Scheduled Reminders job is run manually using the Execute Now option.
Reproduction steps
- Create a custom token using hook_civicrm_container() and implement the civi.token.list and civi.token.eval event listeners.
- Add a new Scheduled Reminder (I'm using membership end date) and include the custom token in the email message.
- Create a Cron Job to run civicrm/bin/cron.php periodically (I run every 15 minutes).
- Enable the Send Scheduled Reminders job and set to run Always.
- Trigger the reminder appropriately (I create a new membership and set the end date to trigger).
- Note the custom token is not included in the resulting email after the cron run.
- Now trigger a new reminder and click Execute Now on the Scheduled Reminders job (before the next cron run).
- Note the custom token is evaluated properly and included in the resulting email message.
Current behaviour
Custom token not included in Scheduled Reminder email when initiated by Cron Job
Expected behaviour
Custom token should be included in Scheduled Reminder email when initiated by Cron Job.
Environment information
- CiviCRM: 5.47.2
- PHP: 7.4.28
- CMS: WordPress 5.9.2
- Database: MySQL
- Web Server: Apache