# Keep Selected Roles Out of Beaver Builder

> Sends users without the chosen capability back to the normal page if they try to open Beaver Builder, and hides its admin bar link from them.

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

## Code

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

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

    wp_safe_redirect( remove_query_arg( array( 'fl_builder', 'fl_builder_ui' ) ) );
    exit;
}, 1 );

add_action( 'admin_bar_menu', function ( $wp_admin_bar ) use ( $wpide_bb_capability ) {
    if ( ! current_user_can( $wpide_bb_capability ) ) {
        $wp_admin_bar->remove_node( 'fl-builder-frontend-edit-link' );
    }
}, 999 );
```

## Notes

Beaver Builder Pro's user access settings offer finer control; this is a quick lock for one capability.

## How to use it

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