Forums

My New plugin needs Help (2 posts)

  1. mrthrust
    Member
    Posted 5 months ago #

    Hi,

    Ok ive created my new plugin, everything is working the way it should,
    the only issue im having is setting up wp_schedule_event() & having it display any information so that i can debug what is happening..

    Ive registered my options on install, one of which you can select when you want the event to run:

    function timetocheck_reccurences()
    {
    	// add a schedule to the existing set
    	$schedules = array(
    	'daily' => array('interval' => 86400,
    		'display' => __('Once Daily')),
    	'weekly' => array('interval' => 604800,
    		'display' => __('Every Week')),
    	'fortnightly' => array('interval' => 1209600,
    		'display' => __('Every Fortnight')),
    	'Monthly' => array('interval' => 2629743.83,
    		'display' => __('Every Month'))
    	);
    	return $schedules;
    }

    as you can see from the code above, I've added various periods which can be selected from the options page, daily, weekly, fortnightly, monthly, this is when im having trouble,

    When the options page is updated, I take the value from the drop down box which relates to the timetocheck: ie; 1 = daily, 2 = weekly, etc..

    this is then stored in the options table, the value is used in another function were it grabs the value using the get_option();

    now this function should set an event when its to be fired, when it dose fire it sends out an email, then it should update the wp_next_schedule(),

    the event is fired on (plugin activation)

    wp_schedule_event(time(), 'fortnightly', 'my_event');

    the my_event function basically sends out an Email..
    that's about it.. but i need to specify when it gets send out, ie: daily weekly etc etc...

    im having difficulty plugging into this from my own function, or any function for that matter..

    Ive read over the documentation, I've looked at various other plugins and how they use the wp_schedule_event()

    but for the life of me, its still not pluggin into the cron,

    Any help would be great..

  2. Dennis2000
    Member
    Posted 4 months ago #

    as I know wp_schedule_event() relies on wp-pseudo-cron, which depends on blog visitors traffic. If there is no traffic on the blog the cron job will not be performed in time. I am having a problem with this issue. I wonder if it is possible to schedule real *nix Cronjob execute wp-pseudo-cron on hourly/daily basis?

Reply

You must log in to post.

About this Topic