Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adding an "author" dropdown to the Media Uploader
<?php
// Just an example. Probably doesn't work.
add_filter('attachment_fields_to_edit', 'add_media_author_field', 10, 2);
add_filter('attachment_fields_to_save', 'save_media_author'), 10, 2);
function add_media_author_field($fields, $post) {
// add the dropdown to $fields
$fields['media-author'] = array(
'label' => __('Credit:'),
'input' => 'html',
'html' => wp_dropdown_users( array( 'echo' => 0 );
);
return $fields;
}
function save_media_author($post, $attachment) {
$attachment->post_author = $_POST('media_author');
return $post;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment