# Show Bricks Elements Only to Logged-In or Logged-Out Visitors

> Skips rendering any Bricks element with the CSS class "wpide-logged-in" for guests and "wpide-logged-out" for members, a quick alternative to setting conditions on each element.

- Type: PHP
- Runs: Frontend only
- Category: [Page Builders & Themes](https://wpide.com/library/category/page-builders/)
- Tags: bricks, visibility, members
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/bricks-visibility-login-classes/

## Code

```php
add_filter( 'bricks/element/render', function ( $render, $element ) {
    if ( ! $render || ! is_object( $element ) || empty( $element->settings['_cssClasses'] ) ) {
        return $render;
    }

    if ( function_exists( 'bricks_is_builder' ) && bricks_is_builder() ) {
        return $render;
    }

    $classes = ' ' . $element->settings['_cssClasses'] . ' ';

    if ( false !== strpos( $classes, ' wpide-logged-in ' ) && ! is_user_logged_in() ) {
        return false;
    }

    if ( false !== strpos( $classes, ' wpide-logged-out ' ) && is_user_logged_in() ) {
        return false;
    }

    return $render;
}, 10, 2 );
```

## Notes

Add the class in the element's Style > CSS > CSS classes field (not a global class).

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show Bricks Elements Only to Logged-In or Logged-Out Visitors" 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/
