AI Verified

Name

Remove menus from dashboard for non Admin users

About

This snippets allow you to hide dashboards menus for non-admin users.

Language

PHP

Rating

Voted: 3 by 3 user(s)

How to Setup Snippet

You can change this code to disable other pages.

Codevault

exemplos

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.1

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

Website/ Profile URL:

https://tecladigital.pt

Snippet Source:

https://tecladigital.pt

History

Last modified:

06/07/2024

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Remove menus from dashboard for non Admin users

 
                    
1// Remove menu items together with the subpages /submenus
2$user = wp_get_current_user();
3$allowed_roles = array('editor', 'author', 'shop_manager');
4if( array_intersect($allowed_roles, $user->roles ) ) {
5 // Stuff here for allowed roles
6 
7add_action( 'admin_menu', 'remove_admin_menu_items', 999 );
8 
9 function remove_admin_menu_items() {
10 
11 remove_menu_page('edit.php?post_type=page');
12 remove_menu_page('edit.php');
13 remove_menu_page('themes.php');
14 remove_menu_page('tools.php');
15 remove_submenu_page('themes.php','nav-menus.php' ); // in this case is a sub-menu
16}
17}

3

Related Snippets

Please see some snippets below related to this snippet..

WordPress Admin

AI Verified

0

Register Custom Widget Areas

Added: 1 year ago

Last Updated: 1 year ago

This snippet allows you to create custom widget areas that can be used throughout your WordPress site.

WordPress Admin

AI Verified

0

remove options menu e snipettcode menu

Added: 1 year ago

Last Updated: 1 year ago

remove the options and code snippets menu for non-admin users if they have "manage_options" capability.

WordPress Admin

AI Verified

0

Custom Color Key

Added: 7 months ago

Last Updated: 7 months ago

Adds a color-coded key at the top of specific admin page.

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

WordPress Admin

AI Verified

3

Remove menus from dashboard for non Admin users

Added: 1 year ago

Last Updated: 1 day ago

This snippets allow you to hide dashboards menus for non-admin users.

WordPress Admin

AI Verified

0

remove options menu e snipettcode menu

Added: 1 year ago

Last Updated: 1 year ago

remove the options and code snippets menu for non-admin users if they have "manage_options" capability.

WordPress Admin

AI Verified

0

Give editors access to manage options (to access some plugins)

Added: 1 year ago

Last Updated: 1 year ago

it give the editor role the manage_options capability in some cases it is necessary to access some plugins.