0

Post Status Transition add_action フックを使用して呼び出される関数で get_post_meta を使用しようとすると、機能しません。

同じ関数を別の場所から直接呼び出すと、正常に動作します。

どうしたの?

/* 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