I have a simple cron job set up in wordpress:
add_action( 'event_hook', 'do_this_function');
wp_schedule_single_event( time() + 300, 'event_hook', array('testvariable') );
I use the function do_this_function() to send an email to a user two weeks after they have done a thing.
However, I realize now that 'event_hook' can only be in the cron job queue ONCE at the same time! I need multiple two week count downs to be running at the same time. I am a bit lost on how this can be done.
What is the workaround to this limitation? The only thing that comes to my mind is:
1 Schedule the "event_hook" to run once per day or so.
2 Call a function that will look at the arguments of the "event_hook" cron job. I would put user emails, time when email must be sent and other info in a multidimensional array
3 Iterate the multidimensional array, send email if two weeks have passed, then delete same information from the cron job array
4 Use a separate function for adding the new information from new users to the cron job array when users trigger need for email in two weeks.
Would this work?