Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Sms_cron_job

Sms_cron_job

// Scheduled Action Hook
function ( ) {
	
		global $wpdb;
	
		$Count   = "SELECT count(`post`.`id`) as `Count` FROM `wp_posts` as `post`
					  INNER JOIN `wp_postmeta` as `meta`
				      ON `post`.`ID`= `meta`.`post_id`
				  	  WHERE `post`.`post_type` = 'iappointment'
				      AND `meta`.`meta_key` = 'appointment_date'
					  AND `post`.`post_date` = '2016-06-18 00:00:00'
					  ORDER BY `Id` DESC";
	
		$id   = "SELECT `post`.`id` as `Id` FROM `wp_posts` as `post`
					INNER JOIN `wp_postmeta` as `meta`
				    ON `post`.`ID`= `meta`.`post_id`
					WHERE `post`.`post_type` = 'iappointment'
					AND `post`.`post_date` = '2016-06-18 00:00:00'
					ORDER BY `Id` DESC";
	
	
		$Dates = "SELECT `meta`.`meta_value` as `Date` FROM `wp_posts` as `post`
			  INNER JOIN `wp_postmeta` as `meta`
			  ON `post`.`ID`= `meta`.`post_id`
			  WHERE `post`.`post_type` = 'iappointment'
			  AND `meta`.`meta_key` = 'appointment_date'
			  		 AND `post`.`post_date` = '2016-06-18 00:00:00'
	
	  		  ";
	
		$Tel  = "SELECT `meta`.`meta_value` as `Tel` FROM `wp_posts` as `post`
			 INNER JOIN `wp_postmeta` as `meta`
			 ON `post`.`ID`= `meta`.`post_id`
			 WHERE `post`.`post_type` = 'iappointment'
			 AND `meta`.`meta_key` = 'appointment_tell'
			 		 AND `post`.`post_date` = '2016-06-18 00:00:00'
	
			 ";
	
		$time  = "SELECT `meta`.`meta_value` as `Time` FROM `wp_posts` as `post`
			 INNER JOIN `wp_postmeta` as `meta`
			 ON `post`.`ID`= `meta`.`post_id`
			 WHERE `post`.`post_type` = 'iappointment'
			 AND `meta`.`meta_key` = 'appointment_time'
			 		 AND `post`.`post_date` = '2016-06-18 00:00:00'
	
			 ";
	
	
		$count = $wpdb->get_results($Count)[0]->Count;
	
		for($i=0;$count>$i;$i++) {
			echo "Date: ".$wpdb->get_results($Dates)[$i]->Date." _ ";
			echo "Tel: ".$wpdb->get_results($Tel)[$i]->Tel." _ ";
			echo "Time: ".$wpdb->get_results($time)[$i]->Time." _ ";
			echo "<br>";
		}
	
		add_option( 'myhack_extraction_length', 'ASD', '', 'yes' );
		update_option( 'myhack_extraction_length', 'asdadasd' );
	
		echo get_option( 'myhack_extraction_length' );
	
}

// Schedule Cron Job Event
function Sms_cron_job() {
	if ( ! wp_next_scheduled( '' ) ) {
		wp_schedule_event( time(), 'daily', '' );
	}
}
add_action( 'wp', 'Sms_cron_job' );