#20: map_meta_cap
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 | |
/** | |
* Only allow super admins to upload files | |
* | |
* @see map_meta_cap() | |
* | |
* @param array $caps Primitive capabilities assigned to meta caps. | |
* @param string $cap Meta capability. | |
* @param int $user_id The current user id. | |
* @param array $args An array of arguments, sometimes empty. | |
* | |
* @return array An array of capabilities. | |
*/ | |
function wpdocs_map_meta_cap( $caps, $cap, $user_id, $args ) { | |
if ( 'upload_files' == $cap && ! is_super_admin( $user_id ) ) | |
$caps[] = 'do_not_allow'; | |
return $caps; | |
} | |
add_filter( 'map_meta_cap', 'wpdocs_map_meta_cap', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment