Discover in this tutorial how to hide the settings menu of a WordPress plugin in WordPress admin sidebar using code.
As a fan of minimalism, I recommend you to remove all the elements that you are not going to use from Genesis and WordPress child themes.
This is especially useful for your customers, because you’ll avoid them “noise” and favor them to have at hand only what they really need to modify.
For example, do you want to remove the menu that is added to the WordPress admin sidebar for a particular plugin?
The result would look something like this:
And here are the instructions:
Snippet to remove the menu for a plugin in WordPress
You’re going to see several examples so you can learn how the code works and adapt it to your needs.
Shall we get started?
Add the following code snippet to your functionality plugin:
With the above example, the WordPress side menu tabs referring to these plugins will no longer be displayed:
- WP Forms
- Ninja Forms
- Gravity Forms
- WooCommerce Analytics
- WooCommerce Marketing
- Genesis Blocks
- Code Snippets
- Restrict Content Pro
As you can see, in some cases it’s very easy to deduce the slug to hide a plugin (like WooCommerce or Ninja Forms), but others are more complicated (like WP Forms or Gravity Forms).
Don’t know the slug of the plugin you want to remove from the menu?
Then add this snippet temporarily to the end of your functionality plugin:
This snippet will cause the arrays of all the menu items on your website to be displayed.
Don’t worry because it will only be seen in the back-end, while the front-end of the website for visitors will remain unchanged.
The important argument is , that’s the one you have to put in remove_menu_page( ‘value of ’ ). In this example we are talking about RCP, but you can look here for the one you want to hide in your case.
When you’ve got the slug from the argument, delete this second snippet that displays the arrays. You don’t need it anymore.
Do you want to remove a particular plugin’s menu from the WordPress settings? Now you know how.
This is especially useful if you combine it with the user role (using the current_user_can function).
Any questions? Let me know in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉