Consider using the Rules module (together with Rules Scheduler
, a sub-module of it), as explained in the 3 steps below.
Step 1: Create a field to store the appointment date
Add a field to the "user" entity with machine name (say) field_next_appointment. Allow only 1 date (the store the "next" appointment), but don't make it required.
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" : "Friendly reminder about your upcoming event",
"message" : "This is a reminder about the upcoming event that you have an upcoming event on [user-to-notify:field_next_appointment] ...",
"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 Rules to be created (in Rules export format, just import it in your own environment via copy-paste):
{ "rules_on_new_user_event_registration" : {
"LABEL" : "On new user event registration",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "rules_scheduler" ],
"ON" : { "user_update" : [] },
"IF" : [
{ "entity_has_field" : { "entity" : [ "account" ], "field" : "field_next_appointment" } }
],
"DO" : [
{ "schedule_delete" : {
"component" : "rules_send_email_notification",
"task" : "[account:name]"
}
},
{ "schedule" : {
"component" : "rules_send_email_notification",
"date" : {
"select" : "account:field-next-appointment",
"date_offset" : { "value" : 259200 }
},
"identifier" : "[account:name]",
"param_user_to_notify" : [ "account" ]
}
}
]
}
}
Note that this rule above refers to the Rules Component from the previous step.
The date_offset (=259200) corresponds to "7 days in advance", which may need review / tuning. Also note that schedule_delete
part of it to ensure that previously "scheduled" reminders get removed when updating the data field.
If needed, you could also use the Field Permissions module to set field-level permissions to edit, view and create fields on any entity.
Note: Using Rules to send an email x days after a user registers also contains quite some details that may help you.