You can go about it this way, explanation in pseudo code and in the comments.
Create a function like the following in your functions.php file:
/**
* This function collects the tasks that are due in a week and sends a reminder
**/
function check_user_tasks_week_before() {
// query which Completion Dates are in a week
// loop through the results (if any)
// and send every user in the result (or every task that is almost due) the email:
// Send a mail:
wp_mail( '[email protected]',
'Your task should be completed in a week',
'Hey, the deadline for your task blablabla is due in a week, get going or else!');
}
(For info about how to attach an image see this page at the WordPress codex.)
To schedule the task with wp_cron
, so it runs every day, create a function like this in the file functions.php:
// If the task does not exist yet, it is created here:
if ( ! wp_next_scheduled( 'my_task_hook' ) ) {
// you can specify what time() it should run (it is a unix timestamp)
// in your case 'daily' would be a good choice:
wp_schedule_event( time(), 'daily', 'my_task_hook' );
}
add_action( 'my_task_hook', 'check_user_tasks_week_before' );