WordPress 5.0 introduced Gutenberg – an entirely new editor interface for posts and pages, allowing WordPress users to create blocks of content. It’s a drag-and-drop system, based on building content from pre-created blocks. In our previous article, we have shared with you how to build custom blocks in Gutenberg without coding and today let’s look into how to restrict or disable Gutenberg blocks in the WordPress block editor.
You can either disable blocks for all users or restrict access to blocks based on user roles or user accounts. You can do this in three ways – through Block Manager, through plugins and through code. We will discuss all three ways in this article.
Method 1 – Disable Gutenberg Blocks via Block Manager
This is probably the easiest way to disable the blocks. This feature was introduced in WordPress 5.2, so if you have 5.2 or a newer version installed you can follow this method.
First click the 3 dots in the top-right corner, and then click “Block Manager”.
To disable any blocks you don’t want to use, just uncheck the boxes next to the blocks you want to hide.
Method 2 – Disable Gutenberg Blocks With Code
Now we will enable you to restrict/disable blocks by simply using a code. Be very careful while applying codes or you will end up with a broken website in your hands. You can manually disable Gutenberg editor blocks with your own code using the allowed_block_types filter. Just add the code to your child theme’s functions.php or you can use a plugin like Code Snippets to manage the code.
Here you can choose the blocks you want to enable and all the other blocks will be disabled. For example, to enable the paragraph block and disable all other blocks, you can use the code given below.
To enable more blocks, you need to just add the block slugs to the array.
To enable only certain blocks for posts, then the following code can be used.
To find the block slugs that you need to include in the array, you can use the Gutenberg code editor.
Method 3 – Restrict or Disable Gutenberg Blocks With Plugins
1. Disable Gutenberg Plugin
If you are not confident enough in your coding skills, you can use plugins to help you disable the blocks. The Disable Gutenberg plugin will help you disable Gutenberg completely, or selectively disable posts, pages, roles, post types, and theme templates.
You can download the Disable Gutenberg plugin from the repository for free. Then click on “Install Now” and activate the plugin. The default plugin settings are configured to hide all traces of the Gutenberg Block Editor, and fully restore the original Classic Editor. Further options for customizing when/where Gutenberg is enabled are available in the plugin settings.
If you uncheck the “Complete Disable” option, you can disable Gutenberg for certain roles, post types, page templates, and post IDs.
Also read: Best Gutenberg Block Plugins
2. PublishPress Blocks – Advanced Gutenberg Blocks, Permissions, CSS and Layouts Plugin
If you are looking for an option to enable or disable blocks for some users, then PublishPress Blocks – Advanced Gutenberg Blocks, Permissions, CSS and Layouts plugin can help you. Apart from adding your own custom, reusable CSS styles for your blocks, you can control who can use each block, including default WordPress blocks. It has many new blocks including accordions, galleries, sliders, tabs, maps, tables, and recent posts.
You can install and activate the plugin from the WordPress repository. Then go to PublishPress Blocks in your dashboard and click New Profile.
Create a profile and Save it.
Then go to the Profile Attribution area and choose which users will use this profile. You can choose either user accounts or user roles or both. If you want to disable Gutenberg blocks for all the users, just select all the user roles to apply this profile globally.
By default, all the blocks are enabled. To choose which blocks are available to users with this profile, go to the Blocks List and disable the blocks you want to block. You can even disable blocks from other third-party plugins.
Save the changes and the users to each profile will only see the blocks that are still active.
Also read: How to Customize WordPress Dashboard Easily
We hope we have equipped you with enough information to disable all/some blocks of Gutenberg editor at your convenience. If you need more assistance, just drop us a line below in the comments section. Also for more WordPress tips, subscribe to our Newsletter too.