Take away WordPress Admin Menu Objects for Particular Person Roles?

So, you created an internet site on your buyer and are afraid that he/she shall be questioning round Plugins and Customizer messing one thing up? And now you might want to know easy methods to take away WordPress admin menu gadgets for particular person roles? Good, since you’re in the precise place.

On this publish I’m going to indicate you two strategies easy methods to take away WordPress Admin Menu gadgets. For those who’re prepared, then dive in. Earlier than you dive within the code under, I might counsel you to try the video right here under. In any other case, it might be a bit complicated what to make use of and easy methods to use.

Video: Take away WordPress Admin Menu Objects for Particular Person Roles and Particular Customers?

Technique 1: Use Admin Menu Editor Plugin

Admin Menu Editor is an efficient and easy to make use of plugin which helps you to manually edit the Dashboard menu. With the couple of clicks you may reorder the menus, present/conceal particular gadgets, change permissions and many others. You may obtain it right here.

If you might want to take away admin menu merchandise you would want to buy a Professional model, although. Due to this fact, I’m going to indicate you easy methods to to that by your self with the assistance of couple of code snippets.

Technique 2: Take away WordPress Admin Menu Objects Programmatically

First, you might want to resolve whether or not you’re going so as to add the code snippet inside your baby theme’s features.php file or use plugin known as Code Snippet for it.

I might counsel the Code Snippets choice as a result of you’ll not lose your modifiations in case you modify theme, must deactivate one thing and many others.

Yet one more factor, although – these snippets right here under will simply conceal these menu gadgets, they won’t revoke entry to the direct hyperlinks. If you wish to revoke the entry you then would nee yo search for an additional methodology.

Take away WordPress First Stage Admin Menu Objects?

Paste this half inside you Code Snipepts plugin. Take note of the feedback contained in the code as a result of this may inform you which a part of the code removes what. So, if you wish to take away Posts menu, then simply uncomment it and go away this half.

remove_menu_page( 'edit.php' ); //Posts

Now, this operate right here under will present you easy methods to take away first degree admin menu gadgets (Feedback, Plugins, Instruments and many others. Be reminded that in case you conceal first degree menu then all of the submenus shall be mechanically hidden. Additionally, this snippet will take away your Replace submenu which is situated underneath Dashboard menu

operate hide_menu() {

   	 /* DASHBOARD */
	 // remove_menu_page( 'index.php' ); // Dashboard + submenus
   	 // remove_menu_page( 'about.php' ); // WordPress menu
   	 remove_submenu_page( 'index.php', 'update-core.php');  // Replace 

   	 /* REMOVE DEFAULT MENUS */
	 remove_menu_page( 'edit-comments.php' ); //Feedback
	 remove_menu_page( 'plugins.php' ); //Plugins
	 remove_menu_page( 'instruments.php' ); //Instruments
  	 remove_menu_page( 'customers.php' ); //Customers
  	 // remove_menu_page( 'edit.php' ); //Posts
	 // remove_menu_page( 'add.php' ); //Media
	 // remove_menu_page( 'edit.php?post_type=web page' ); // Pages
	 // remove_menu_page( 'themes.php' ); // Look
  	 // remove_menu_page( 'options-general.php' ); //Settings

}
add_action('admin_head', 'hide_menu');

You probably have any third get together plugin associated menus you might want to take away then simply add a brand new line, seize a final a part of the menu URL and exchange it contained in the code. For Instance: if I wish to take away Elementor then the complete URL is https://yoursite.com/wp-admin/admin.php?web page=elementor

Seize the final half “elementor” and add it to the code like this:

remove_menu_page( 'elementor' ); 

Take away WordPress Admin Menu submenu Objects?

This time we’re going to make use of remove_submenu_page with two half in it. See this code right here under.

remove_submenu_page( 'options-general.php', 'options-writing.php');  

This code will take away Writing subenu (option-writing.php) which is situated underneath Settings menu (options-general). So, if you wish to take away submenu you then would want to vary each components contained in the code. I do know, it might be complicated however let me clarify within the subsequent chapter.

take away third get together plugin associated menus or submenus?

I’ve a plugin known as Fluent Varieties put in and I wish to take away submenu International Settings. Now I’ll check out the Fulent varieties first degree menu merchandise URL which is https://yousite.com/wp-admin/admin.php?web page=fluent_forms (see the daring half? Write it down.)

Subsequent I’ll seize a International Settings submenu URL which is https://yoursite.com/wp-admin/admin.php?web page=fluent_forms_settings (see the daring half? Write it down.)

Nicely, now you may have each components you would want to make use of on this code in an effort to take away International Settings submenu:

remove_submenu_page( 'fluent_forms', 'fluent_forms_settings');  

take away WordPress Setting web page menus and submenus?

Now, to make your life a bit simpler here’s a snippet which is able to give a great place to begin. It will take away Setting web page submenus. If you wish to take away complete Settings menu (with submenus) then add this line to your sinppet.

remove_menu_page( 'options-general.php' ); //Settings

One once more remark out or take away these traces you don’t wish to take away and uncomment those you might want to take away.

operate hide_submenu() {

     	  /* REMOVE SETTINGS PAGE SUBMENUS */
  	// remove_submenu_page( 'options-general.php', 'options-permalink.php');  // Permalinks
  	   remove_submenu_page( 'options-general.php', 'options-writing.php');  // Writing
  	   remove_submenu_page( 'options-general.php', 'options-reading.php');  // Studying
  	   remove_submenu_page( 'options-general.php', 'options-discussion.php');  // Dialogue
  	   remove_submenu_page( 'options-general.php', 'options-media.php');  // Media
  	// remove_submenu_page( 'options-general.php', 'options-general.php');  // Normal
  	   remove_submenu_page( 'options-general.php', 'options-privacy.php');  // Privateness

}
add_action('admin_head', 'hide_submenu');

Take away Wooocommerce Advertising and marketing Menu?

Possibly you may have a small store, and you don’t have any want for Woocommerce Makrketing menu, and subsequently you might want to take away it. Nicely, you should utilize this piece of code right here under.

// This code will take away Woocommerce advertising menu (Analytics, MArketing and many others). 
add_filter( 'woocommerce_admin_features', operate( $options ) {
    return array_values(
        array_filter( $options, operate($characteristic) {
            return $characteristic !== 'advertising';
        } ) 
    );
} );

Take away WordPress Customizer Admin Menu Merchandise?

Most likely it isn’t a clever concept to take away Look menu since you would additionally conceal Widgets and Menus submenu gadgets. Due to this fact, take into account it rigorously. In any other case, if you wish to take away submenus from Look add these traces inside one of many snippets you used above.

// remove_submenu_page( 'themes.php', 'widgets.php' ); // conceal Widgets
// remove_submenu_page( 'themes.php', 'nav-menus.php' ); // conceal Menus
   remove_submenu_page( 'themes.php', 'themes.php' ); // conceal the theme choice submenu
   remove_submenu_page('themes.php', 'theme-editor.php'); // conceal Theme editor

There’s another problem although – Customizer which want a bit completely different code snippet. However – I’ve received you lined. Simply add this half inside your snippet.

$customizer_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customise.php' );
remove_submenu_page( 'themes.php', $customizer_url );

Take away WordPress Admin Menu Objects for Particular Person Roles?

Right here’s the state of affairs for you.

  • You created a website on your buyer
  • He/she wants entry to the positioning
  • Buyer want administrator rights however you don need him/her to entry all of the menus

So, what to do? Nicely, let’s create a brand new person function which has all admin rights however the function known as Website Admin.

Clone a WordPress Administrator person function?

It’s simple. Simply go to the Code Snippets and paste this code right here under.

add_action('init', 'cloneRole');

operate cloneRole() {
 $adm = get_role('administrator');
 $adm_cap= array_keys( $adm->capabilities ); //get administator capabilities
 add_role('site_admin', 'Website admin'); //create new function
 $new_role = get_role('site_admin');
  foreach ( $adm_cap as $cap ) {
   $new_role->add_cap( $cap ); //clone administrator capabilities to new function
  }
}

Press on “Save and activate” button and the function is cloned. Now you may delete this snippet.

Take away WordPress Admin Menu Objects for Particular Person Roles?

It’s relatively simple. Check out the function slug within the snippet we used to clone a job. There’s a person function known as Website admin and the slug is site_admin. Write it down since you’re gonna want it now.

Now, if you wish to take away WordPress admin menu gadgets for particular person function (Website Admin, for instance) you then would want to switch your snippet a bit. One thing like this:

operate hide_siteadmin() {
  
// Use this for particular person function. Change site_admin half accordingly
if (current_user_can('site_admin')) {

   /* DASHBOARD */	
   remove_submenu_page( 'index.php', 'update-core.php');  // Replace
    }
}
add_action('admin_head', 'hide_siteadmin');

As you see, we eliminated Replace submenu for Website admin person function.

Take away WordPress Admin Menu Objects for Particular Customers?

As soon as once more, that is pretty simple. This time you would want to switch your snippet to appear like this one right here under.

operate hide_demouser() {
  
//  Change username "demouser"
 $person = wp_get_current_user();
    if($person && isset($user->user_login) && 'demouser' == $user->user_login) { 

   /* DASHBOARD */	
   remove_submenu_page( 'index.php', 'update-core.php');  // Replace
    }
}
add_action('admin_head', 'hide_demouser');

Let put all the things collectively

If all the things I described here’s a bit complicated then simply seize this code right here under and take away the traces you don’t want. It comprises all the things I confirmed you above and take away menu gadgets for Website Admin person function. Contained in the code there’s a commented out half for Demouser.

As a bonus I included some examples for the well-known plugin menus you could wish to take away.

operate hide_menu() {
  
// Use this for particular person function. Change site_admin half accordingly
if (current_user_can('site_admin')) {
  
// Uncomment the half under in case you want it to particular person. Change username "demouser"
/* $person = wp_get_current_user();
    if($person && isset($user->user_login) && 'buyer' == $user->user_login) { */
   
   	/* DASHBOARD */
	// remove_menu_page( 'index.php' ); // Dashboard + submenus
   	// remove_menu_page( 'about.php' ); // WordPress menu
   	remove_submenu_page( 'index.php', 'update-core.php');  // Replace
 		
   	/* WP DEFAULT MENUS */
	 remove_menu_page( 'edit-comments.php' ); //Feedback
	 remove_menu_page( 'plugins.php' ); //Plugins
	 remove_menu_page( 'instruments.php' ); //Instruments
  	 remove_menu_page( 'customers.php' ); //Customers
  	 // remove_menu_page( 'edit.php' ); //Posts
	 // remove_menu_page( 'add.php' ); //Media
	 // remove_menu_page( 'edit.php?post_type=web page' ); //Pages
	 // remove_menu_page( 'themes.php' ); //Look
  	 // remove_menu_page( 'options-general.php' ); //Settings

   	  /* SETTINGS PAGE SUBMENUS */
  	//remove_submenu_page( 'options-general.php', 'options-permalink.php');  // Permalinks
  	  remove_submenu_page( 'options-general.php', 'options-writing.php');  // Writing
  	  remove_submenu_page( 'options-general.php', 'options-reading.php');  // Studying
  	  remove_submenu_page( 'options-general.php', 'options-discussion.php');  // Dialogue
  	  remove_submenu_page( 'options-general.php', 'options-media.php');  // Media
  	//remove_submenu_page( 'options-general.php', 'options-general.php');  // Normal
  	  remove_submenu_page( 'options-general.php', 'options-privacy.php');  // Privateness
  
      /* APPEARANCE SUBMENUS */
      // remove_submenu_page( 'themes.php', 'widgets.php' ); // conceal Widgets
      // remove_submenu_page( 'themes.php', 'nav-menus.php' ); // conceal Menus
	 remove_submenu_page( 'themes.php', 'themes.php' ); // conceal the theme choice submenu
 	 remove_submenu_page('themes.php', 'theme-editor.php'); // conceal Theme editor
   
  /* HIDE CUSTOMIZER MENU */
  $customizer_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customise.php' );
  remove_submenu_page( 'themes.php', $customizer_url );

   /* Plugin associated submenus underneath Settings web page */
   remove_submenu_page( 'options-general.php', 'webpc_admin_page' ); // WebP converter
   remove_submenu_page( 'options-general.php', 'kadence_blocks' ); // Kadence Blocks
     
	  /* third get together plugin menus */
	  // remove_menu_page( 'snippets' ); // Code snippets
	  // remove_menu_page( 'elementor' ); // Elementor
	  // remove_menu_page( 'rank-math' ); // Rank Math
	  // remove_menu_page( 'Wordfence' ); // Wordfence
	  // remove_menu_page( 'WPML' ); // WPML
   	  // remove_menu_page( 'fluent_forms' ); // Fluent Varieties
  	  // remove_menu_page( 'ct-dashboard' ); // Blocksy
    }
      }
add_action('admin_head', 'hide_menu');

Take away WordPress Admin Bar Objects?

Yet one more factor. Though you eliminated menu gadgets from the WordPress Admin there’s a small downside. That’s: customizer menu merchandise continues to be seen on front-end admin bar. So, if you wish to take away Worpress admin bar gadgets then this snippet will take away a few of them for Website Admin person function.

// Take away frontend admin bar gadgets
operate remove_admin_bar_items($wp_admin_bar) {
    if (current_user_can('site_admin')) {
        // Plugin associated admin-bar gadgets
        $wp_admin_bar->remove_node('blocksy_preview_hooks');
        // WordPress Core Objects 
        $wp_admin_bar->remove_node('updates');
        $wp_admin_bar->remove_node('feedback');
        // $wp_admin_bar->remove_node('new-content');
        $wp_admin_bar->remove_node('wp-logo');
        //$wp_admin_bar->remove_node('site-name');
        //$wp_admin_bar->remove_node('my-account');
        //$wp_admin_bar->remove_node('search');
        $wp_admin_bar->remove_node('customise');
    }
}
add_action('admin_bar_menu', 'remove_admin_bar_items', 999);

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart
Scroll to Top