Skip to content

Instantly share code, notes, and snippets.

@kisildev
Last active March 1, 2019 10:52
Show Gist options
  • Select an option

  • Save kisildev/f189382af27e433d77fb5bf2449ab6b1 to your computer and use it in GitHub Desktop.

Select an option

Save kisildev/f189382af27e433d77fb5bf2449ab6b1 to your computer and use it in GitHub Desktop.
Remove & Restore Wp Plugins
/******************* HIDE/SHOW WORDPRESS PLUGINS MENU ITEM *********************/
/**
* Remove and Restore ability to Add new plugins to site
*/
function remove_plugins_menu_item($role_name){
$role = get_role( $role_name );
$role->remove_cap( 'activate_plugins' );
$role->remove_cap( 'install_plugins' );
$role->remove_cap( 'upload_plugins' );
$role->remove_cap( 'update_plugins' );
}
function restore_plugins_menu_item($role_name){
$role = get_role( $role_name );
$role->add_cap( 'activate_plugins' );
$role->add_cap( 'install_plugins' );
$role->add_cap( 'upload_plugins' );
$role->add_cap( 'update_plugins' );
}
// remove_plugins_menu_item('administrator');
restore_plugins_menu_item('administrator');
/*******************************************************************************/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment