Skip to content

Instantly share code, notes, and snippets.

@tddewey
Forked from WerdsWords/map_meta_cap.php
Last active December 20, 2015 07:09
Show Gist options
  • Save tddewey/6090765 to your computer and use it in GitHub Desktop.
Save tddewey/6090765 to your computer and use it in GitHub Desktop.
<?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 contextual 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