Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Schedule Cron Job Event

exmaple of Schedule Cron Job Event

// Scheduled Action Hook
function ohad_hook_function($param1 = 'val1', $param2 = 'val2', $param3 = 'val3') {
    echo $param1 .' '. $param2 .' '. $param3;
}

// Custom Cron Recurrences
function ohad_cron_job_custom_recurrence( $schedules ) {
	$schedules['ohadly'] = array(
		'display' => __( 'every ohad', 'textdomain' ),
		'interval' => 604800,
	);
	return $schedules;
}
add_filter( 'cron_schedules', 'ohad_cron_job_custom_recurrence' );

// Schedule Cron Job Event
function ohad_cron_job() {
	if ( ! wp_next_scheduled( 'ohad_hook_function' ) ) {
		wp_schedule_event( current_time( 'timestamp' ), 'ohadly', 'ohad_hook_function' , array('val1','val2','val3'));
	}
}
add_action( 'wp', 'ohad_cron_job' );