Last active
August 10, 2020 16:48
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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