Skip to content

Instantly share code, notes, and snippets.

Created July 26, 2013 17:33
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
#20: map_meta_cap
* 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