WordPress.org

Ready to get started?Download WordPress

Forums

using wp_schedule_event (2 posts)

  1. mainecampus
    Member
    Posted 4 years ago #

    I'm developing a plugin that uses wp schedule event, but I can't get it to fire. Here's my code:

    function more_reccurences() {
    return array(
    'everyminute' => array('interval' => 60, 'display' => 'Once Every Minute'),
    );
    }
    add_filter('cron_schedules', 'more_reccurences');
    
    register_activation_hook(__FILE__, 'mails_activation');
    add_action('mail_event', 'check_for_mails');
    
    function mails_activation() {
    	wp_schedule_event(time(), 'everyminute', 'mail_event');
    }
    
    function check_for_mails() {
    	global $wpdb;
    
    	$message = "Line 1\nLine 2\nLine 3";
    	$message = wordwrap($message, 70);
    	mail('caffeinated@example.com', 'My Subject', $message);
    
    }
  2. David Miller
    Member
    Posted 4 years ago #

    Your value for $recurrance ('everyminute') is not valid. The only valid values are 'hourly', 'twicedaily', and 'daily'

    I created a plugin that I wanted to fire every five minutes so I set 12 scheduled events with times 5 minutes apart that all called the same hook and with an 'hourly' recurrance.

    See http://codex.wordpress.org/Function_Reference/wp_schedule_event for more info on wp_schedule_event.

Topic Closed

This topic has been closed to new replies.

About this Topic