So I'm working on a custom save-post filter. It's working to handle the external API calls I'm using to generate information, which is super awesome. In total, I'm grabbing file info from an API, downloading a couple of files, writing them to a directory, zipping them and deleting them. It all works. During this process I'm extracting data points from the API stuff and storing them as variables to be saved as meta fields. My function looks like this, minus all of the stuff you don't need to see (assume that the function works EXCEPT update_post_meta() isn't firing).
function stuff_save( $post_id ) {
$post_type = get_post_type($post_id);
// If this is just a revision, do nothing.
if ( wp_is_post_revision( $post_id )|| "animations" != $post_type )
return;
/**code to generate data points**/
$datapoint = get_post_meta($post_id,custom_field,1);
$update_var= string_from_API_Call;
/**uses $datapoint to do a thing; I'm using this result elsewhere, can echo it, and it's successful.**/
$hat = update_post_meta( $post_id, 'field_name', $update_var );//returns a value, but that number doesn't correspond with any meta key in my database nor does the data save anywhere.
}
}add_action( 'save_post', 'stuff_save' );
Now if I echo $hat it returns a number, like it would - but that meta key not only doesn't exist when I look into my post_meta table, but it increments when I refresh the script just the same.
Little help overflowvians?
$hat
you addecho get_metadata_by_mid( 'post', $hat )
?object(stdClass)#5889 (4) { ["meta_id"]=> string(3) "297" ["post_id"]=> string(2) "post_id" ["meta_key"]=> string(9) "field_name" ["meta_value"]=> string(79) "update_var" }
But that value 297 doesn't exist in my database as any type of meta id, nor can I search the entire database for the string.