# Keep Selected Roles Out of the Bricks Builder

> Sends users without the chosen capability back to the page when they try to open the Bricks builder and hides its admin bar link, as an extra lock on top of Bricks' builder access settings.

- Type: PHP
- Runs: Run everywhere
- Category: [Page Builders & Themes](https://wpide.com/library/category/page-builders/)
- Tags: bricks, roles, permissions
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/bricks-builder-access-by-role/

## Code

```php
// Capability needed to open the builder.
$wpide_bricks_capability = 'manage_options';

add_action( 'template_redirect', function () use ( $wpide_bricks_capability ) {
    if ( ! isset( $_GET['bricks'] ) || ! is_user_logged_in() || current_user_can( $wpide_bricks_capability ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
        return;
    }

    wp_safe_redirect( remove_query_arg( 'bricks' ) );
    exit;
}, 1 );

add_action( 'admin_bar_menu', function ( $wp_admin_bar ) use ( $wpide_bricks_capability ) {
    if ( ! current_user_can( $wpide_bricks_capability ) ) {
        $wp_admin_bar->remove_node( 'edit_with_bricks' );
    }
}, 999 );
```

## Notes

Change manage_options to edit_others_pages to let editors in too.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Keep Selected Roles Out of the Bricks Builder" 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/
