How to show parent pages on a specific page if user is logged in?

The database hasn’t been queried yet on init, there is no $post or $wp_query. See the Action Reference for the order actions are executed. Try moving your code to the template_redirect action.