1

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.

5
  • 1
    Can you update your question to indicate what version of Drupal you're using? – Les Lim Jun 18 at 15:03
  • 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 at 20:11
  • Sorry @LesLim, It's Drupal 8 i'm using, post updated. – David Jun 19 at 16:55
  • 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 at 10:57
  • 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 at 0:08
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, privacy policy and cookie policy

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