# Limit the Blocks Authors and Contributors Can Use

> Gives authors and contributors a short list of everyday blocks (text, headings, lists, images, quotes, embeds) while editors and administrators keep every block.

- Type: PHP
- Runs: Run everywhere
- Category: [Block Editor](https://wpide.com/library/category/gutenberg/)
- Tags: block-editor, permissions, roles
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/allowed-blocks-per-role/

## Code

```php
// Blocks available to authors and contributors.
$wpide_role_blocks = array(
    'core/paragraph', 'core/heading', 'core/list', 'core/list-item', 'core/quote', 'core/image',
    'core/gallery', 'core/embed', 'core/separator', 'core/table', 'core/buttons', 'core/button', 'core/details',
);

add_filter( 'allowed_block_types_all', function ( $allowed, $context ) use ( $wpide_role_blocks ) {
    if ( current_user_can( 'edit_others_posts' ) ) {
        return $allowed;
    }

    if ( empty( $context->post ) ) {
        return $allowed;
    }

    return $wpide_role_blocks;
}, 20, 2 );
```

## Notes

Users who can edit others' posts (editors and administrators) are not limited. Edit the block list to fit your site.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Limit the Blocks Authors and Contributors Can Use" 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/
