[wp-hackers] wp_schedule_event being triggered multiple times

Andrew Ferguson andrew at fergcorp.com
Tue Feb 27 04:41:45 GMT 2007

I'm working on a plugin that uses uses the inbuilt cron system to check for
Blogs by email.

I'm having an issue where emails are posted several times over. For example,
I would send an email to the account specified. The plugin would perform its
hourly check, I would check the site later and I would see multiple
(somewhere between 1-12) posts of the email, each with same time stamp. My
best guess is that multiple hits are occurring at the moment the cron'd
event should be triggered. This causes the the event to execute multiple
times before some setting is updated to prevent further executions for this
round (i.e. prevent it from executing this hour). Like I said, my best

Here's the code (being released under GPL):

function fergcorp_checkEmailPosts(){

	$handle = fopen(get_bloginfo('wpurl')."/wp-mail.php", "r");


add_action('fergcorp_checkEmailPosts_hook', 'fergcorp_checkEmailPosts' );

if (!wp_next_scheduled('fergcorp_checkEmailPosts_hook')) {
	wp_schedule_event( time(), 'hourly', 'fergcorp_checkEmailPosts_hook' );

Any ideas?

-Andrew Ferguson

More information about the wp-hackers mailing list