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.
Opens WPIDE on
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
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.