Skip to main content
added 454 characters in body
Source Link

Use publish_future_post action hook. Contrary to what Codex says, it is not deprecated, and it works with WordPress 4.8.2. Your code should be:

function my_test_future_post( $post_id ) {
    update_post_meta( $post_id, 'hook_fired', 'true' );
}
add_action( 'publish_future_post', 'my_test_future_post' );

Tested!

Update

If you are concerned about publish_future_post hook being deprecated, use transition_post_status hook:

function my_test_future_post( $new, $old, $post ) {
    if ( $post->post_type == 'post' && $new == 'publish' && $old == 'future' )
        update_post_meta( $post->ID, 'hook_fired', 'You bet!' );
}
add_action( 'transition_post_status', 'my_test_future_post', 10, 3 );

Tested in functions.php and plugins.

Use publish_future_post action hook. Contrary to what Codex says, it is not deprecated, and it works with WordPress 4.8.2. Your code should be:

function my_test_future_post( $post_id ) {
    update_post_meta( $post_id, 'hook_fired', 'true' );
}
add_action( 'publish_future_post', 'my_test_future_post' );

Tested!

Use publish_future_post action hook. Contrary to what Codex says, it is not deprecated, and it works with WordPress 4.8.2. Your code should be:

function my_test_future_post( $post_id ) {
    update_post_meta( $post_id, 'hook_fired', 'true' );
}
add_action( 'publish_future_post', 'my_test_future_post' );

Tested!

Update

If you are concerned about publish_future_post hook being deprecated, use transition_post_status hook:

function my_test_future_post( $new, $old, $post ) {
    if ( $post->post_type == 'post' && $new == 'publish' && $old == 'future' )
        update_post_meta( $post->ID, 'hook_fired', 'You bet!' );
}
add_action( 'transition_post_status', 'my_test_future_post', 10, 3 );

Tested in functions.php and plugins.

Source Link

Use publish_future_post action hook. Contrary to what Codex says, it is not deprecated, and it works with WordPress 4.8.2. Your code should be:

function my_test_future_post( $post_id ) {
    update_post_meta( $post_id, 'hook_fired', 'true' );
}
add_action( 'publish_future_post', 'my_test_future_post' );

Tested!