Skip to content

Instantly share code, notes, and snippets.

@RiFi2k
Created April 11, 2017 02:43
Show Gist options
  • Save RiFi2k/ab9e143124fca59ec5887f8456369161 to your computer and use it in GitHub Desktop.
Save RiFi2k/ab9e143124fca59ec5887f8456369161 to your computer and use it in GitHub Desktop.
// Add the hook action
add_action('transition_post_status', 'send_new_post', 10, 3);
// Listen for publishing of a new post
function send_new_post($new_status, $old_status, $post) {
if('publish' === $new_status && 'publish' !== $old_status && $post->post_type === 'post') {
// Do something!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment