Skip to content

Instantly share code, notes, and snippets.

@azanebrain
Created January 23, 2014 00:24
Show Gist options
  • Save azanebrain/8570435 to your computer and use it in GitHub Desktop.
Save azanebrain/8570435 to your computer and use it in GitHub Desktop.
Hide plugins and settings panels from the WordPress admin panels to make sure certain users don't deactivate them, or change settings.
add_filter( 'all_plugins', 'hide_plugin_list' );
function hide_plugin_list( $plugins ) {
if ( is_admin() ) {
//Only run this if we're in the Admin panels
unset( $plugins[ 'advanced-custom-fields/acf.php'] );
//Admin only plugins
if ( ! current_user_can( 'administrator' ) ) {
unset( $plugins[ 'better-wp-security/better-wp-security.php'] );
unset( $plugins[ 'broken-link-checker/broken-link-checker.php'] );
unset( $plugins[ 'velvet-blues-update-urls/velvet-blues-update-urls.php'] );
unset( $plugins[ 'wordpress-seo/wp-seo.php'] );
unset( $plugins[ 'wp-smushit/wp-smushit.php'] );
unset( $plugins[ 'wp-super-cache/wp-cache.php'] );
}
return $plugins;
}//if is_admin
}//hide_plugin_list
function hide_options_panels() {
if (is_admin()){
//Only run this if we're in the Admin panels
if ( ! current_user_can('administrator') ) {
remove_menu_page( 'edit.php?post_type=acf' ); //advanced custom fields
remove_menu_page( 'better-wp-security' );
}
}//if is_admin
}//options_panels()
add_action('admin_menu', 'zan_hide_options_panels' , 999);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment