0

When I try to use get_post_meta in a function that is called using the Post Status Transition add_action hook, it doesn't work.

If I call the same function directly from somewhere else, it works fine.

What's going on?

/* notification */

function new_notification($post){

    $meta = get_post_meta($post->ID,'meta_key',true);

    return $meta; // returns str if function run directly, returns empty (false) with hook

}

add_action('auto-draft_to_draft', 'new_notification');
add_action('new_to_draft', 'new_notification');
4

0 回答 0