Skip to main content
edited body
Source Link

Update:

Now that you've changed your question (and made my original answer look completely wrong!):

I haven't used the hook future_to_publish, but I have successfully used the transition_post_status action (also referenced in the Codex page) to detect status changes.

Something similar to this has worked for me before:

add_action( 'transition_post_status', 'my_status_change', 10, 3 );

function my_status_change( $new_status, $old_status, $post ) {
    if ($new_status=="future"$old_status=="future" && $old_status=="publish"$new_status=="publish"){
        // do stuff....
    }
}

I think you might have mixed up 2 hooks? The Codex refers to the following hooks:

  1. {old_status}_to _{new_status} Hook

An {old_status}to{new_status} action will execute when a post transitions from {old_status} to {new_status}.

In your case: future_to_publish (future_to_post won't work because post isn't a status

  1. {status}_{post_type} Hook

A {status}_{post_type} action will execute when a post of type {post_type} transitions to {status} from any other status.

In your case: This would be publish_post (I think this may be where you got them mixed up?)

I assume you only want future to publish transitions so try:

add_action( 'future_to_publish', 'future_publish' );

Update:

Now that you've changed your question (and made my original answer look completely wrong!):

I haven't used the hook future_to_publish, but I have successfully used the transition_post_status action (also referenced in the Codex page) to detect status changes.

Something similar to this has worked for me before:

add_action( 'transition_post_status', 'my_status_change', 10, 3 );

function my_status_change( $new_status, $old_status, $post ) {
    if ($new_status=="future" && $old_status=="publish"){
        // do stuff....
    }
}

I think you might have mixed up 2 hooks? The Codex refers to the following hooks:

  1. {old_status}_to _{new_status} Hook

An {old_status}to{new_status} action will execute when a post transitions from {old_status} to {new_status}.

In your case: future_to_publish (future_to_post won't work because post isn't a status

  1. {status}_{post_type} Hook

A {status}_{post_type} action will execute when a post of type {post_type} transitions to {status} from any other status.

In your case: This would be publish_post (I think this may be where you got them mixed up?)

I assume you only want future to publish transitions so try:

add_action( 'future_to_publish', 'future_publish' );

Update:

Now that you've changed your question (and made my original answer look completely wrong!):

I haven't used the hook future_to_publish, but I have successfully used the transition_post_status action (also referenced in the Codex page) to detect status changes.

Something similar to this has worked for me before:

add_action( 'transition_post_status', 'my_status_change', 10, 3 );

function my_status_change( $new_status, $old_status, $post ) {
    if ($old_status=="future" && $new_status=="publish"){
        // do stuff....
    }
}

I think you might have mixed up 2 hooks? The Codex refers to the following hooks:

  1. {old_status}_to _{new_status} Hook

An {old_status}to{new_status} action will execute when a post transitions from {old_status} to {new_status}.

In your case: future_to_publish (future_to_post won't work because post isn't a status

  1. {status}_{post_type} Hook

A {status}_{post_type} action will execute when a post of type {post_type} transitions to {status} from any other status.

In your case: This would be publish_post (I think this may be where you got them mixed up?)

I assume you only want future to publish transitions so try:

add_action( 'future_to_publish', 'future_publish' );
Fixed typo in code
Source Link

Update:

Now that you've changed your question (and made my originalyoriginal answer look completely wrong!),:

I haven't used those functions specificallythe hook future_to_publish, but I havehave successfully used the transition_post_status action (also referenced in the Codex page) to detect status changes.

Something similar to this has worked for me before:

add_action( 'transition_post_status', 'my_status_change', 10, 3 );

function my_status_change( $new_status, $old_status, $post ) {
    if ($new_status=="future" && $new_status=="publish"$old_status=="publish"){
        // do stuff....
    }
}

I think you might have mixed up 2 hooks? The Codex refers to the following hooks:

  1. {old_status}_to _{new_status} Hook

An {old_status}to{new_status} action will execute when a post transitions from {old_status} to {new_status}.

In your case: future_to_publish (future_to_post won't work because post isn't a status

  1. {status}_{post_type} Hook

A {status}_{post_type} action will execute when a post of type {post_type} transitions to {status} from any other status.

In your case: This would be publish_post (I think this may be where you got them mixed up?)

I assume you only want future to publish transitions so try:

add_action( 'future_to_publish', 'future_publish' );

Update:

Now that you've changed your question (and made my originaly answer look completely wrong!), I haven't used those functions specifically but I have successfully used the transition_post_status action (also referenced in the Codex page) to detect status changes.

Something similar to this has worked for me before:

add_action( 'transition_post_status', 'my_status_change', 10, 3 );

function my_status_change( $new_status, $old_status, $post ) {
    if ($new_status=="future" && $new_status=="publish"){
        // do stuff....
    }
}

I think you might have mixed up 2 hooks? The Codex refers to the following hooks:

  1. {old_status}_to _{new_status} Hook

An {old_status}to{new_status} action will execute when a post transitions from {old_status} to {new_status}.

In your case: future_to_publish (future_to_post won't work because post isn't a status

  1. {status}_{post_type} Hook

A {status}_{post_type} action will execute when a post of type {post_type} transitions to {status} from any other status.

In your case: This would be publish_post (I think this may be where you got them mixed up?)

I assume you only want future to publish transitions so try:

add_action( 'future_to_publish', 'future_publish' );

Update:

Now that you've changed your question (and made my original answer look completely wrong!):

I haven't used the hook future_to_publish, but I have successfully used the transition_post_status action (also referenced in the Codex page) to detect status changes.

Something similar to this has worked for me before:

add_action( 'transition_post_status', 'my_status_change', 10, 3 );

function my_status_change( $new_status, $old_status, $post ) {
    if ($new_status=="future" && $old_status=="publish"){
        // do stuff....
    }
}

I think you might have mixed up 2 hooks? The Codex refers to the following hooks:

  1. {old_status}_to _{new_status} Hook

An {old_status}to{new_status} action will execute when a post transitions from {old_status} to {new_status}.

In your case: future_to_publish (future_to_post won't work because post isn't a status

  1. {status}_{post_type} Hook

A {status}_{post_type} action will execute when a post of type {post_type} transitions to {status} from any other status.

In your case: This would be publish_post (I think this may be where you got them mixed up?)

I assume you only want future to publish transitions so try:

add_action( 'future_to_publish', 'future_publish' );
Updated answer with new requirements from OP
Source Link

Update:

Now that you've changed your question (and made my originaly answer look completely wrong!), I haven't used those functions specifically but I have successfully used the transition_post_status action (also referenced in the Codex page) to detect status changes.

Something similar to this has worked for me before:

add_action( 'transition_post_status', 'my_status_change', 10, 3 );

function my_status_change( $new_status, $old_status, $post ) {
    if ($new_status=="future" && $new_status=="publish"){
        // do stuff....
    }
}

I think you might have mixed up 2 hooks? The Codex refers to the following hooks:

  1. {old_status}_to _{new_status} Hook

An {old_status}to{new_status} action will execute when a post transitions from {old_status} to {new_status}.

In your case: future_to_publish (future_to_post won't work because post isn't a status

  1. {status}_{post_type} Hook

A {status}_{post_type} action will execute when a post of type {post_type} transitions to {status} from any other status.

In your case: This would be publish_post (I think this may be where you got them mixed up?)

I assume you only want future to publish transitions so try:

add_action( 'future_to_publish', 'future_publish' );

I think you might have mixed up 2 hooks? The Codex refers to the following hooks:

  1. {old_status}_to _{new_status} Hook

An {old_status}to{new_status} action will execute when a post transitions from {old_status} to {new_status}.

In your case: future_to_publish (future_to_post won't work because post isn't a status

  1. {status}_{post_type} Hook

A {status}_{post_type} action will execute when a post of type {post_type} transitions to {status} from any other status.

In your case: This would be publish_post (I think this may be where you got them mixed up?)

I assume you only want future to publish transitions so try:

add_action( 'future_to_publish', 'future_publish' );

Update:

Now that you've changed your question (and made my originaly answer look completely wrong!), I haven't used those functions specifically but I have successfully used the transition_post_status action (also referenced in the Codex page) to detect status changes.

Something similar to this has worked for me before:

add_action( 'transition_post_status', 'my_status_change', 10, 3 );

function my_status_change( $new_status, $old_status, $post ) {
    if ($new_status=="future" && $new_status=="publish"){
        // do stuff....
    }
}

I think you might have mixed up 2 hooks? The Codex refers to the following hooks:

  1. {old_status}_to _{new_status} Hook

An {old_status}to{new_status} action will execute when a post transitions from {old_status} to {new_status}.

In your case: future_to_publish (future_to_post won't work because post isn't a status

  1. {status}_{post_type} Hook

A {status}_{post_type} action will execute when a post of type {post_type} transitions to {status} from any other status.

In your case: This would be publish_post (I think this may be where you got them mixed up?)

I assume you only want future to publish transitions so try:

add_action( 'future_to_publish', 'future_publish' );
Source Link
Loading