# Show Elementor Sections Only to Logged-In or Logged-Out Visitors

> Hides any Elementor container, section or widget with the CSS class "wpide-logged-in" from guests, and anything with "wpide-logged-out" from members, without Elementor Pro.

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

## Code

```php
$wpide_el_login_visibility = function ( $should_render, $element ) {
    if ( ! $should_render || ! is_object( $element ) || ! method_exists( $element, 'get_settings' ) ) {
        return $should_render;
    }

    if ( class_exists( '\Elementor\Plugin' ) && \Elementor\Plugin::$instance->editor && \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
        return $should_render;
    }

    $classes = ' ' . $element->get_settings( '_css_classes' ) . ' ' . $element->get_settings( 'css_classes' ) . ' ';

    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 $should_render;
};

foreach ( array( 'widget', 'section', 'column', 'container' ) as $wpide_el_type ) {
    add_filter( "elementor/frontend/{$wpide_el_type}/should_render", $wpide_el_login_visibility, 10, 2 );
}
```

## Notes

Add the class under Advanced > CSS Classes. Elements stay visible in the editor so you can still edit them.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show Elementor Sections 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/
