• Resolved Davis Shaver

    (@davisshaver)


    Is post meta data accessible during transition_post_status?

    I have hooked a function to ‘transition_post_status’ but am seeing null or empty returns for functions like get_post_meta and get_post_custom on valid keys.

    Here is how I am hooking the function to ‘transition_post_status’. Perhaps the problem is related to priority?

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    No, and priority will not help. Post meta is added well after ‘transition_post_status’. Try ‘add_post_meta’ action if you need access to database metadata. The post ID is passed as the 1st function parameter. Fires once for every meta value added.

    If you’re looking for metadata submitted with the post, see if it’s available in $_POST inside the ‘transition_post_status’ action.

    Thread Starter Davis Shaver

    (@davisshaver)

    Thank you for your help. $_POST didn’t have what I needed, but I am switching to implementation based on save_post instead.

    Moderator bcworkz

    (@bcworkz)

    Unfortunately, ‘save_post’ fires almost immediately after ‘transition_post_status’ so you are not really any closer to where post meta is dealt with.

    If it helps any, the function that drives the entires save post process, including the post itself and meta data is wp_write_post() (source). You can see in the source there are no filter or action hooks available. However some of the functions called do have hooks, hopefully you can find something that works for you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Is post meta accessible during transition_post_status?’ is closed to new replies.