Skip to content

Instantly share code, notes, and snippets.

@whyisjake
Created January 4, 2018 04:57
Show Gist options
  • Save whyisjake/38404febaeaf2a9e36e74a58904c08c3 to your computer and use it in GitHub Desktop.
Save whyisjake/38404febaeaf2a9e36e74a58904c08c3 to your computer and use it in GitHub Desktop.
<?php
/**
* Test Callback on Publish
*
* @package News-Nerds
*/
add_action( 'publish_post', 'callback_function_to_run_on_publish', 999 );
/**
* Callback method to kick of a cron event
*
* @param int $post_id Post ID.
* @return void
*/
function callback_function_to_run_on_publish( $post_id ) {
if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
return;
}
wp_schedule_single_event( time(), 'actual_function_that_i_want_call', array( $post_id ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment