Skip to content

Instantly share code, notes, and snippets.

@aaronjorbin
Created March 6, 2014 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronjorbin/9399084 to your computer and use it in GitHub Desktop.
Save aaronjorbin/9399084 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin name: LaFours
Description: Removes caps for actions that should take place in code, not in UI
Author: Aaron Jorbin
Author URI: http://aaron.jorb.in/
Version: 0.1
*/
function lafours_map_meta_cap($caps, $cap, $user_id, $args) {
// This is LaFours White Straw Cap
$not_allow = array(
'update_plugins',
'delete_plugins',
'install_plugins',
'activate_plugins',
'edit_plugins',
'update_themes',
'delete_themes',
'install_themes',
'edit_themes',
'switch_themes',
'edit_theme_options',
'manage_options',
'update_core',
'edit_files',
);
if( in_array($cap, $not_allow) ) {
$caps = array();
$caps[] = 'do_not_allow';
}
return $caps;
}
add_filter('map_meta_cap', 'lafours_map_meta_cap', 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment