I've been making a modification to Subscribe2 plugin so that batches of emails can be sent out with a delay between them (because my hosting only allow 300 emails to be sent per hour).
The bare bones of my modification are as follows:
<?php
class s2class {
function send_emails($email = array()) {
$recipient = $email[0];
$subject = $email[1];
$mailtext = $email[2];
$headers = $email[3];
$status = @wp_mail($recipient, $subject, $mailtext, $headers);
return $status;
}
function mail() {
$delays = 3600;
$email = array ($recipient, $subject, $mailtext, $headers);
$status = $this->send_emails($email);
wp_schedule_single_event(time()+$delays, 'send_batch_emails', $email);
}
function subscribe2() {
add_action('send_batch_emails', array(&$this, 'send_emails'), 10, 1);
}
}
?>
I can send out the emails without a delay using
$status = $this->send_emails($email);
and
wp_schedule_single_event(time()+$delays, 'send_batch_emails', $email);
puts all the correct data into the Cron queue but doesn't send the $email array to the send_emails() function.
I'm not at all familiar with using classes and suspect that using wp_schedule_single_event inside a class is causing the problem passing the data with add_action.
I've searched high and low on Google and haven't found anything that seems to correspond with this problem.