How to Hide WordPress Admin Dashboard Links

How to Hide WordPress Admin Dashboard Links

March 24, 2023
wordpress website checklist

The WordPress admin dashboard provides a lot of functionality, but not every user role needs access to all the links and features. For example, you may want to simplify the interface for contributors or editors by hiding links they don’t need or prevent certain roles from accessing sensitive options like themes or plugins.

In this post, I’ll show you how to hide WordPress admin dashboard links using a simple code snippet. This approach is perfect for tailoring the dashboard to specific user roles and keeping things clean and organized.

Why Hide Admin Dashboard Links?

There are several reasons to customize the admin dashboard by hiding links:

  • Improve User Experience: Simplify the interface for non-technical users by removing unnecessary options.
  • Enhance Security: Prevent unauthorized users from accessing certain areas.
  • Avoid Mistakes: Reduce the chances of accidental changes to critical settings.

How to Hide Admin Dashboard Links

You can hide admin dashboard links by removing menu items based on user roles or capabilities. Here’s how you can do it.

Step 1: Add the Code Snippet

Add the following code snippet to your theme’s functions.php file or use a plugin like Code Snippets for better management.

Copy to Clipboard

Step 2: How It Works

  • current_user_can('manage_options'): This checks if the user has the manage_options capability, which is typically reserved for administrators.
  • remove_menu_page('slug'): This removes the menu page associated with the specified slug. For example:
    • 'tools.php' removes the Tools menu.
    • 'edit.php?post_type=page' removes the Pages menu.
    • 'edit-comments.php' removes the Comments menu.
  • Role-Based Control: The condition ensures that only users without admin privileges are affected.

Step 3: Customize the Snippet

You can modify the snippet to fit your specific requirements by using different menu slugs. Here are some common menu slugs:

  • Dashboard: index.php
  • Posts: edit.php
  • Media: upload.php
  • Users: users.php
  • Settings: options-general.php

To hide the dashboard entirely for certain users, you can include:

Copy to Clipboard

Advanced Customization: Hide Submenus

If you want to hide specific submenu items, use remove_submenu_page(). For example:

Copy to Clipboard

Step 4: Test the Changes

  1. Log in as a non-admin user (e.g., Editor or Contributor).
  2. Navigate to the admin dashboard.
  3. Verify that the hidden menu items are no longer visible for the restricted user.

Admins will still have access to all menu items.

Use Cases for This Snippet

This customization is useful for:

  • Client Projects: Simplify the dashboard for clients with limited technical expertise.
  • Membership Sites: Restrict contributors or subscribers to only the areas they need.
  • Collaborative Blogs: Limit access to certain features for contributors or editors.

Bonus Tip: Use Plugins for Granular Control

If you’re managing a large site or need advanced options, consider using plugins like Admin Menu Editor or User Role Editor. These plugins provide a user-friendly interface to customize menus without writing code.

Final Thoughts

Hiding unnecessary admin dashboard links is a simple way to streamline the WordPress experience for your users. By using the provided code snippets, you can tailor the dashboard based on user roles, enhance security, and create a more focused environment.

Have you tried customizing the WordPress admin menu? Share your thoughts or ask questions in the comments below!

Leave A Comment

SitesByYogi

WordPress Hosting and Support

WordPress Hosting and Support Services

I provide fast, secure WordPress hosting and expert development services, including custom themes, plugins, and tailored solutions for your website’s success.