I have some metadata on my post edit page that saves perfectly using the hook and function below:
add_action('save_post', 'save_meta_data');
function save_meta_data($post_id){
if(isset($_POST['target_url'])) {
update_post_meta($post_id, 'target_url', $_POST['target_url']);
}
};
However, the same logic fails to save the meta data before a post is trashed.
add_action('wp_trash_post', 'save_meta_data');
function save_meta_data($post_id){
if(isset($_POST['target_url'])) {
update_post_meta($post_id, 'target_url', $_POST['target_url']);
}
};
It looks like in the second case that the whole $_POST array is empty. But I know that the function is firing when the post is trashed.
Could some kind soul point out what am I dong wrong and what is the proper way to do this?
Thanks, Ron