WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
    • Business Name Ideas
  • Deals
    • Bluehost Coupon
    • SiteGround Coupon
    • WP Engine Coupon
    • HostGator Coupon
    • Domain.com Coupon
    • Constant Contact
    • View All Deals »
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» Tutorials» How to Remove Menu Item in WordPress Admin Panel

How to Remove Menu Item in WordPress Admin Panel

Last updated on April 29th, 2013 by Editorial Staff
41 Shares
Share
Tweet
Share
Pin
Free WordPress Video Tutorials on YouTube by WPBeginner
How to Remove Menu Item in WordPress Admin Panel

Have you ever worked with a client who has a hard time understanding technology? Well, as a consultant, designer, or developer, it is your job to make things easier for them. WordPress admin panel comes with a lot of options in the menu, but you can get rid of them fairly easily if necessary. With one of our clients, we needed to get rid of few menu items, so it is easier for her to understand things. In this article, we will show you how easy it is to remove a menu item in the WordPress Admin Panel.

For WordPress 3.1 or above, just paste the following code in your theme’s functions.php file:

	add_action( 'admin_menu', 'my_remove_menu_pages' );
	function my_remove_menu_pages() {
		remove_menu_page('link-manager.php');	
	}

In version prior to WordPress 3.1, you would need to paste the following code in your theme’s functions.php file:

function remove_menus () {
global $menu;
	$restricted = array(__('Links'));
	end ($menu);
	while (prev($menu)){
		$value = explode(' ',$menu[key($menu)][0]);
		if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
	}
}
add_action('admin_menu', 'remove_menus');

The code above will get rid of the Links option for all users (including administrators). Only two user roles are allowed to see the Link tab (Administrators and Editors). Now if this is for a multi-author site (where there are many editors), and you as an administrator still want access to the Links menu, then you can add parameters to do so.

You would need to utilize the function current_user_can(), and with a simple if statement, you can get rid of the link menu or other items for specific user role.

This is a very handy trick for consultants and developers who work on larger sites.

Additional Sources

Remove Menu Page
Current User Can Function Reference
User Roles and Capabilities Chart

41 Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • Google Analytics in WordPress

    How to Install Google Analytics in WordPress for Beginners

  • How to Properly Move Your Blog from WordPress.com to WordPress.org

  • Checklist

    Checklist: 15 Things You MUST DO Before Changing WordPress Themes

  • How to Start Your Own Podcast (Step by Step)

    How to Start Your Own Podcast (Step by Step)

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

16 Comments

Leave a Reply
  1. ideadeia says:
    Aug 6, 2014 at 2:42 pm

    But how about some menu items created by a plugin, with pages like “admin.php?page=wpcf-cf” it’s working fine for wp menu items but I cant get it to work with parametized urls,

    Any clue?

    Reply
  2. ThatK1dB says:
    Apr 30, 2014 at 3:08 pm

    Very useful! thanks

    Reply
  3. Will says:
    Feb 25, 2014 at 4:30 pm

    The unset global option still works for newer versions of WordPress if you still want to allow direct access; to properly block the page you do need to use remove_menu_page.

    Reply
  4. Jay says:
    Sep 28, 2012 at 1:03 pm

    Just a note to update this code, admin_init needs to be changed to admin_menu

    Reply
    • Veerle says:
      Apr 28, 2013 at 10:54 am

      +1, please correct this in the article!
      still a popular one ;)

      http://wordpress.org/support/topic/warning-invalid-argument-supplied-for-foreach-in-homesitepublic_htmlxxwp

      Reply
      • Editorial Staff says:
        Apr 29, 2013 at 9:25 am

        Updated the article.

        Reply
  5. gleenk says:
    Jul 4, 2011 at 2:06 pm

    Thank you, but… how can I add link? and metabox (for example only to insert a custom field somewhere, maybe in footer?)

    Reply
  6. jose says:
    May 14, 2011 at 2:34 pm

    How can remove Item, that are installed by plugin like, Contact 7, Poll Daddy or others ? Which are their names on the menu ??

    Thx

    Reply
    • Editorial Staff says:
      May 17, 2011 at 11:48 am

      You would have to look at each plugin’s codes individually.

      Reply
      • kreegahdesign says:
        Oct 30, 2011 at 2:04 pm

        To find what to add where? I would also like to hide the Contact form 7 and SEO admin pages.

        Reply
      • Maggan says:
        Oct 30, 2011 at 2:07 pm

        What line of code would I put in there then? If I wanted to remove Contact form 7 for instance

        Reply
        • wpbeginner says:
          Oct 31, 2011 at 8:01 am

          @Maggan You would have to examine each plugin individually to see what is their menu code.

        • Eric Downs says:
          Jun 19, 2013 at 4:26 pm

          Did you happen to figure out where to look for this?

        • Vali says:
          Apr 21, 2014 at 3:00 pm

          in wp-config.php put this code:

          define( ‘WPCF7_ADMIN_READ_CAPABILITY’, ‘manage_options’ );
          define( ‘WPCF7_ADMIN_READ_WRITE_CAPABILITY’, ‘manage_options’ );

  7. Alan says:
    May 11, 2011 at 5:24 pm

    You wouldn’t happen to know how to create username specific “if” conditions for the menus do you?

    Reply
  8. Alan says:
    May 11, 2011 at 8:06 am

    I was just looking up how to do this the other day and came across a nice bit of code that will leave the links for admins but remove them for everybody else.

    function remove_menus () {
    global $menu;
    if( (current_user_can(‘install_themes’)) ) { $restricted = array(__()); }
    else { $restricted = array( __(‘Posts’),__(‘Links’), __(‘Pages’), __(‘Tools’), __(‘Users’), __(‘Settings’), __(‘Profile’)); } // hide these for other roles
    end ($menu);
    while (prev($menu)){
    $value = explode(‘ ‘,$menu[key($menu)][0]);
    if(in_array($value[0] != NULL?$value[0]:”” , $restricted)){unset($menu[key($menu)]);}
    }
    }
    add_action(‘admin_menu’, ‘remove_menus’);

    Reply

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
RafflePress - WordPress Giveaway and Contest Plugin
RafflePress
Giveaway and Contest Plugin for WordPress. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 30 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2020 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2020)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2020)
    • SiteGround Reviews from 4196 Users & Our Experts (2020)
    • Bluehost Review from Real Users + Performance Stats (2020)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Create an Email Newsletter the RIGHT WAY (Step by Step)
    • Free Business Name Generator (A.I Powered)
    • How to Create a Free Business Email Address in 5 Minutes (Step by Step)
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2020 – Step by Step Guide
Deals & Coupons (view all)
Revive Old Post
Revive Old Post Coupon
Get 15% OFF on Revive Old Post WordPress social share plugin.
The Constant Contact logo
Constant Contact Coupon
Get 20% OFF Constant Contact, one of the best email marketing service for small businesses.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).
Join our team: We are Hiring!

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
  • Free Business Tools
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • RafflePress
  • Smash Balloon

Copyright © 2009 - 2021 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

Managed by Awesome Motive | WordPress hosting by SiteGround | WordPress CDN by MaxCDN | WordPress Security by Sucuri.