Skip to content

Instantly share code, notes, and snippets.

@yoosuf yoosuf/transaction.php
Last active Jul 11, 2017

What would you like to do?
WordPress: When a post is published, trigger an event
* Add this function somewhere in functions.php
* You will see there is nothing is magic in WordPress
function on_all_status_transitions( $new_status, $old_status, $post ) {
if ('publish' == $new_status && 'publish' != $old_status && 'trash' != $old_status) {
// Your code comes here
add_action( 'transition_post_status', 'on_all_status_transitions', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.