How can I hide the TOP Navigation menu if users are not logged in [duplicate]

You can check if user logged in by calling is_user_logged_in function. Modify your menu rendering call like this:

<?php if ( is_user_logged_id() ) : ?>
    <!-- above html related to menu is going here -->
    <?php // wp_nav_menu call ... ?>
    <!-- below html related to menu is going here -->
<?php endif; ?>

error code: 523