Add CSS for logged in users

This is a very simple function. The use case in the example is to hide specific menu links from users who aren’t logged so it’s checking if users are not logged in. We can use this and add to it a bit. Eg. we could have CSS for specific users roles, etc.

				
					function add_css_for_non_logged_in_users() {
    if ( ! is_user_logged_in() ) {
        echo '<style>
                .main-header-menu li.e-n-menu-item:nth-of-type(4),
                .my-esim-mobile-menu-link {
                    display: none;
                }
            </style>';
    }
}
add_action('wp_head', 'add_css_for_non_logged_in_users');