Schedule Cron Job Event

Overview

Use this tool to create custom code for WordPress Cron Jobs using wp_schedule_event() function.

Usage

  • Fill in the user-friendly form.
  • Click the “Update Code” button.
  • Copy the code to your project.
  • Or save it as a snippet and share with the community.

Examples

If you are still learning how to use this tool, check out the following examples:

The function used in the code.
Translation file Text Domain. Optional.
The first time you want the event to occur.
How often the event should reoccur.
Create custom intervals using the "cron_schedules" filter in wp_get_schedules().
The name of an action hook to execute.
Comma separated list of arguments to pass to the hook function(s).
Custom code to be executed.
  Save Snippet
// Scheduled Action Hook
function send_mail( ) {
		return wp_mail( '[email protected]', 'Notification TEST', 'TEST', null );
}
add_action( 'send_mail', 'send_mail' );

// Schedule Cron Job Event
function custom_cron_job() {
	if ( ! wp_next_scheduled( 'send_mail' ) ) {
		wp_schedule_event( current_time( 'timestamp' ), 'daily', 'send_mail' );
	}
}
add_action( 'wp', 'custom_cron_job' );