Skip to content

Instantly share code, notes, and snippets.

@steve-brett
Last active August 10, 2020 16:48
Show Gist options
  • Save steve-brett/b5a845e4996923e0bb32d79f57ed3df5 to your computer and use it in GitHub Desktop.
Save steve-brett/b5a845e4996923e0bb32d79f57ed3df5 to your computer and use it in GitHub Desktop.
Allow users who don't have edit_posts capability to edit attachment metadata
<?php
/**
* Allow users who don't have edit_posts capability to edit attachment metadata.
* From @grapplerulrich on https://core.trac.wordpress.org/ticket/19834#comment:42
*/
add_filter( 'register_post_type_args', function( $args, $post_type ) {
if ( 'attachment' === $post_type ) {
$args['capabilities']['edit_posts'] = 'upload_files';
$args['capabilities']['upload_files'] = 'upload_files';
}
return $args;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment