Skip to content

Instantly share code, notes, and snippets.

@mjangda
Created February 22, 2010 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mjangda/311369 to your computer and use it in GitHub Desktop.
Save mjangda/311369 to your computer and use it in GitHub Desktop.
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