WordPress.org

Ready to get started?Download WordPress

Forums

Edit Flow
[resolved] some transition_post_status action? (7 posts)

  1. thomask
    Member
    Posted 1 year ago #

    Is there something like transition_post_status action (http://codex.wordpress.org/Post_Status_Transitions) i need to do some actions based on the information, what was previous edit flow action and what is the new one

    http://wordpress.org/extend/plugins/edit-flow/

  2. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    Which information are you wanting to monitor?

  3. thomask
    Member
    Posted 1 year ago #

    new_status, old_status, $post should be OK.

    I have just found, that you got filter ef_notification_status_change what is probably what i am looking for, the problem is, that it seems do not work, as there is still "inherit" / "new" statuses, when i use it, not the custom ones i defined in ef statuses

  4. thomask
    Member
    Posted 1 year ago #

    aaah I see the problem - it cannot work - you are using standard hook add_action( 'transition_post_status', array( $this, 'notification_status_change' ), 10, 3 );

    but this hook does not work because builtin status functionality is crippled (https://core.trac.wordpress.org/ticket/12706)

    so this example http://editflow.org/extend/auto-subscribe-user-groups-for-notifications/ could never work, because your function never recieves proper $new_status and $old_status, but only that stupid default ones with "new" and "inherit"

  5. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    You're correct — transition_post_status fires twice but the Edit Flow code only pays attention to once of those times.

    The example works because it's only ever looking at $new_status.

  6. thomask
    Member
    Posted 1 year ago #

    ufff, it took me some time but i finaly found a solution so you could repair it - fyi repaired action (btw if you would implement it, then do not put it to that notification module, otherwise it will not work if someone got it turned off, it should be imo universal code)

    function transition_post_status($new_status, $old_status, $post) {

    $post = ('inherit' == $new_status) ? get_post($post->post_parent) : $post;
    global $post_status;
    if (!empty($post_status)) {
    $old_status = $post_status;
    $new_status = $post->post_status;
    } else {
    $post_status = $post->post_status;
    return;
    }

    if ($old_status == $new_status) return; // do nothing if no status change

    // now do something with the old and new statuses
    print_r ($old_status);
    print_r ($new_status);
    }

  7. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    Happy to look at a pull request if you want to create one.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic