Using wp_schedule_single_event with arguments to send email

I think you have mismatch in how you pass arguments and how you expect it to work. You pass array of arguments to schedule and expect your hooked function to receive identical array of arguments. This is not the case.

Cron events are processed by do_action_ref_array(), which in turn passes arguments via call_user_func_array().

So your hooked function does not receive array of arguments, it receives multiple arguments – one for each element in your array.

So you need to either wrap array of arguments in array one more time or modify your function to process multiple arguments. Note that for letter you will also need to modify your add_action() call so that required number of arguments is passed instead of just one.

Leave a Comment