Skip to content

Instantly share code, notes, and snippets.

@Kenshino
Created January 24, 2014 15:27
Show Gist options
  • Save Kenshino/8599450 to your computer and use it in GitHub Desktop.
Save Kenshino/8599450 to your computer and use it in GitHub Desktop.
/*-----------------------------------------------------------------------------------*/
/* Media Library Permissions */
/*-----------------------------------------------------------------------------------*/
add_action('pre_get_posts','users_own_attachments');
function users_own_attachments( $wp_query_obj )
{
global $current_user, $pagenow;
if( !is_a( $current_user, 'WP_User') )
return;
if( 'upload.php' != $pagenow && 'media-upload.php' != $pagenow)
return;
if( !current_user_can('delete_pages') )
$wp_query_obj->set('author', $current_user->ID );
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment