0

Hello I was wondering if anybody could help.

I'm using Drupal 8 and for every page that exists I need a custom email to automatically get sent to the page author 11 months after that page was published. It's just to act as a reminder to the author that their page is still published incase they have forgot.

I can't find any info online that outlines exactly what i'm trying to achieve however anything remotely similar I found seems to be using the 'Rules' and 'Scheduler' modules however i'm really not sure how I can achieve what I need to do using them.

Absolutely any help would be amazing, many thanks in advance.

3
  • In D7 this is trivial to do with Rules and Rules Scheduler, and is extensively documented in many places including many answers here on Stack Exchange.
    – anonymous
    Jun 18, 2021 at 20:11
  • 1
    The D7 Rules module came with a rules scheduler module, not to be confused with the scheduler module. The D8 version has no such rules scheduler module and doesn't appear to have any scheduling functionality. Therefore, you'll have to build such feature via custom code.
    – No Sssweat
    Jun 20, 2021 at 10:57
  • 1
    No real need for Rules, you can write a cron hook that adds nodes older than 11 months and add them to a job queue, then process the job queue by sending email(s).
    – Kevin
    Jul 6, 2021 at 0:08

1 Answer 1

0

There isn't a scheduler or Rules available for D8/9 anymore which would've made this easy, but you can build a somewhat simple module that creates a cron job, and in that job you can query each piece of content you want to send emails for, check the 'published' date, find out if it was 11 months ago, and if so email the 'author' of the published content. Then set up a local system cron task to run cron once a day.

You'd obviously want to put checks in place to make sure the email only sends once, and that the user still exists. Setting the conditional to check to make sure that it's 11 months to do the day, and only checking once a day should prevent it from sending more than once for each piece of content.

Your Answer

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

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