# Hide the Custom HTML Block From Non-Administrators

> Removes the Custom HTML block from the inserter for users who cannot post unfiltered HTML, so authors use proper blocks instead of pasting raw markup.

- Type: PHP
- Runs: Admin only
- Category: [Block Editor](https://wpide.com/library/category/gutenberg/)
- Tags: blocks, html, permissions
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/hide-custom-html-block-from-inserter/

## Code

```php
add_action( 'enqueue_block_editor_assets', function () {
    if ( current_user_can( 'unfiltered_html' ) ) {
        return;
    }

    wp_add_inline_script(
        'wp-blocks',
        'wp.hooks.addFilter("blocks.registerBlockType","wpide/hide-html-block",function(settings,name){if(name==="core/html"){settings.supports=Object.assign({},settings.supports,{inserter:false});}return settings;});'
    );
} );
```

## Notes

Existing Custom HTML blocks stay editable; only inserting new ones is hidden.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Hide the Custom HTML Block From Non-Administrators" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
