When I save my post (custom post type: project) I want to get the meta data for a specific key that I just inserted. Based on the value of that key I insert a product in WooCommerce.
What happens is that I get the past value for the meta key, instead of the current/new one. Here's the code I use:
function shortened($post_id){
$key_verkoop_ja_nee = "kaart_verkoop";
//$value_verkoop_ja_nee = get_post_meta($post_id, $key_verkoop_ja_nee, TRUE);
//$value_verkoop_ja_nee = $GLOBALS["wp_object_cache"]->cache["post_meta"][$post_id][$key_verkoop_ja_nee][0];
//$value_verkoop_ja_nee = $_REQUEST[$key_verkoop_ja_nee];
$value_verkoop_ja_nee = $_POST[$key_verkoop_ja_nee];
if($value_verkoop_ja_nee == "Yes"){
//Do a lot of stuf
}
}
add_action( 'save_post_project', 'shortened', 999 );
$_POST and $_REQUEST don't return any value at all, get_post_meta and the $GLOBALS return the past value. I tried edit_post instead of save_post, in/decreased the importance (999) and used global $post in the function. Nothing works.
Any idea how the get the new inserted meta value?
Thanks a lot!