Use the Rules module together with Rules Scheduler
(a sub-module of it) for sending such eMails, as explained in the steps below.
Step 1: Create a field to store the "weaning" date
Assume your weaning date field has a machine name (say) field_weaning_date
, for which only 1 date is allowed.
Step 2: Create a Rules "Component"
Here is the Rules Component to be created, in Rules export format (just import it in your own environment via copy-paste):
{ "rules_send_email_notification" : {
"LABEL" : "Send eMail notification",
"PLUGIN" : "action set",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "user_to_notify" : { "label" : "User to be notified", "type" : "user" } },
"ACTION SET" : [
{ "mail" : {
"to" : [ "user-to-notify:mail" ],
"subject" : "Reminder you requested",
"message" : "This is a reminder that you asked for ...",
"from" : "[site:mail]",
"language" : [ "" ]
}
}
]
}
}
Obviously, the Subject and Content of the eMail may need review / tuning, while you might also want to use some other From eMail ID.
Step 3: Create a "Rule" using the Rules Component
Here is the Rule to be created, in Rules export format (just import it in your own environment via copy-paste):
{ "rules_send_email_on_a_scheduled_date" : {
"LABEL" : "Send eMail on a scheduled date",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "rules_scheduler" ],
"ON" : { "node_presave" : [] },
"IF" : [
{ "entity_has_field" : { "entity" : [ "node" ], "field" : "field_weaning_date" } }
],
"DO" : [
{ "schedule_delete" : { "component" : "rules_send_email_notification", "task" : "[node:nid]" } },
{ "schedule" : {
"component" : "rules_send_email_notification",
"date" : [ "node:field-weaning-date" ],
"identifier" : "[node:nid]",
"param_user_to_notify" : [ "node:author" ]
}
}
]
}
}
The above rule refers to the Rules Component from the previous step.
The schedule_delete
that is part of this rule is to ensure that previously "scheduled" reminders will get removed when updating the data field (so that it only triggers 1 reminder, and with the most recently entered date).
Attention: as per your specs in your question, if anybody different from the "author" ever updates that weaning date, the effect of doing so will be that:
- no eMail will be send on the previously requested "weaning date" (if that is not what you want, then remove the
schedule_delete
part in the rules action in Step 3).
- the "author" will receive another eMail, on the updated weaning date (if that is not what you want, then add a rules condition in Step 3 to verify that the editor's userid matches the author's userid).