Title: [Plugin: Plugins] Basic Schedule Not Working
Last modified: August 20, 2016

---

# [Plugin: Plugins] Basic Schedule Not Working

 *  [J7mbo](https://wordpress.org/support/users/j7mbo/)
 * (@j7mbo)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-plugins-basic-schedule-not-working/)
 * Hi, I’m a newbie to wordpress plugins (but not PHP). I’ve followed a couple of
   tutorials and I simply can’t get a schedule working. I basically want to create
   the equivalent of a cronjob to send today’s posts out to every user of the system.
 * First thing’s first, I can’t even get the most basic schedule working. Please
   advise?
 *     ```
       <?php
       /*
         Plugin Name: testschedule
         Version: 0.1
         Description: A simple plugin to test schedules are working
         Plugin URI: lololol
         Author: Moi
         Author URI: http://www.j7mbo.co.uk
        */
   
       $plugin_dir = plugin_basename(__FILE__);
       $plugin_dir = str_replace(basename($plugin_dir), '', $plugin_dir);
       define('TESTSCHEDULE_DIR', WP_PLUGIN_DIR . '/' . $plugin_dir);
       define('TESTSCHEDULE_URL', WP_PLUGIN_URL . '/' . $plugin_dir);
       define('TESTSCHEDULE_VERSION', 0.1);
   
       class testschedule {
       	private static $instance;
   
       	public static function forge() {
               if (!isset(self::$instance)) {
                   $className = __CLASS__;
                   self::$instance = new $className;
               }
               return self::$instance;
           }
   
       	private function __construct() {
       		add_action('daily_schedule', array($this, 'main') );
       	}
   
       	private function main() {
   
       		// Do something
       		echo '<br><br><br>OMG';
       		die;
       	}
   
       }
   
       global $testschedule;
       $testschedule = testschedule::forge();
   
       register_activation_hook(__FILE__, 'activate');
       register_deactivation_hook(__FILE__, 'deactivate');
   
       function activate() {
       	if ( !wp_next_scheduled( 'daily_schedule' ) ) {
       		wp_schedule_event( '1342021600', 'daily', 'daily_schedule');
       		// Daily at 4:50pm = 1342025400
       	}
       }
   
       function deactivate() {
       	wp_clear_scheduled_hook('activate');
       }
       ```
   
 * [http://wordpress.org/extend/plugins/plugins/](http://wordpress.org/extend/plugins/plugins/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [J7mbo](https://wordpress.org/support/users/j7mbo/)
 * (@j7mbo)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-plugins-basic-schedule-not-working/#post-2892383)
 * I thought I’d add that to get the ‘cronjob’ going, I’ll ping / wget the page 
   to simulate a visitor visiting at the time I need the e-mail sent out.
 *  Thread Starter [J7mbo](https://wordpress.org/support/users/j7mbo/)
 * (@j7mbo)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-plugins-basic-schedule-not-working/#post-2892593)
 * 2 days on, has nobody got experience with this scheduling? Please could somebody
   who has lend a quick hand – it’s not for profit, just for learning. I’ve tried
   repeated clean wordpress installs…

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: Plugins] Basic Schedule Not Working’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/plugins.svg)
 * [Plugins](https://wordpress.org/plugins/plugins/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/plugins/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/plugins/)
 * [Active Topics](https://wordpress.org/support/plugin/plugins/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/plugins/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/plugins/reviews/)

## Tags

 * [wp_schedule_event](https://wordpress.org/support/topic-tag/wp_schedule_event/)

 * 2 replies
 * 1 participant
 * Last reply from: [J7mbo](https://wordpress.org/support/users/j7mbo/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-plugins-basic-schedule-not-working/#post-2892593)
 * Status: not resolved