javascript – How to hide content for logged out users?-ThrowExceptions

Exception or error:

I have a section at the bottom of my page with icons that navigates members (logged-in) from different pages. It consists of ‘profile’, ‘leads’, ‘orders’ and ‘filter’.

I wish for non-logged-in users (customers) not to see this navigation section as the the customers can check a members profile and do not want them entering those pages.

Is there a way to hide this section to non-logged in users?

The section’s class I want to hide is called ‘icon-container’

How to solve:

You can use is_user_logged_in() to check if whether the current visitor is a logged in user.

So, in the php file, you can do it like this:

<?php if (is_user_logged_in()): ?>

  <section>
  </section>

<?php endif; ?>

Thus, the <section> will only be rendered if the user is logged in.

Leave a Reply

Your email address will not be published. Required fields are marked *