Halloween Sale 15% off Ends in See the plans
PHP

Elementor Theme Builder Condition: Logged-In Visitors

Adds a "Logged-in visitors" display condition under Entire Site in Elementor Pro's Theme Builder, so you can show a different header or footer to members.

Don’t have WPIDE yet? Install it on your site

Code

add_action( 'elementor/theme/register_conditions', function ( $conditions_manager ) {
    if ( ! class_exists( '\ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base' ) ) {
        return;
    }

    if ( ! class_exists( 'WPIDE_Elementor_Logged_In_Condition' ) ) {
        class WPIDE_Elementor_Logged_In_Condition extends \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
            public static function get_type() {
                return 'general';
            }

            public function get_name() {
                return 'wpide_logged_in';
            }

            public function get_label() {
                return 'Logged-in visitors';
            }

            public function check( $args ) {
                return is_user_logged_in();
            }
        }
    }

    $general = $conditions_manager->get_condition( 'general' );

    if ( $general ) {
        $general->register_sub_condition( new WPIDE_Elementor_Logged_In_Condition() );
    }
} );

Notes

Needs Elementor Pro. Re-save the template's conditions after enabling this snippet.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.