Created
March 14, 2014 15:48
-
-
Save danielbachhuber/9550397 to your computer and use it in GitHub Desktop.
In multisite, give editors and above the ability to upload whatever they want.
This file contains hidden or 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 editors and above to upload whatever they want | |
*/ | |
add_filter( 'map_meta_cap', function( $caps, $cap, $user_id ) { | |
if ( 'unfiltered_upload' !== $cap ) { | |
return $caps; | |
} | |
if ( user_can( $user_id, 'edit_others_posts' ) ) { | |
if ( false !== ( $key = array_search( 'do_not_allow', $caps ) ) ) { | |
unset( $caps[ $key ] ); | |
} | |
$caps[] = 'unfiltered_upload'; | |
$caps = array_values( $caps ); | |
} | |
return $caps; | |
}, 10, 3 ); | |
/** | |
* Allow editors and above to upload whatever, part two | |
*/ | |
add_filter( 'user_has_cap', function( $allcaps, $caps ) { | |
if ( ! in_array( 'unfiltered_upload', $caps ) ) { | |
return $allcaps; | |
} | |
$allcaps['unfiltered_upload'] = true; | |
return $allcaps; | |
}, 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment