I am trying to create a function that automatically adds a value to the attachment metadata (if it matters, on Audio uploads).
For example, I want to add a value of ‘artist’ and output it as my own specificity (for the sake of the example, just simply ‘test’)
I’ve tried numerous things but each one, thus far, has not worked (and outputs an unspecified error upon uploading the media).
Here’s a couple things I’ve tried:
function auto_update_audio_meta($post_ID) {
add_post_meta( $post_ID, 'artist', 'test');
}
add_action('add_post_meta', 'auto_update_audio_meta');
I’ve also tried hooking to update_post_metadata
, and variations such as
function auto_update_audio_meta() {
wp_update_post_meta( $post->ID, 'artist', 'test');
}
add_action('update_post_metadata', 'auto_update_audio_meta', 10, 5);
What am I doing wrong?