Display different header/navigation bar based on if user logged in

Hi!

I have two different nav bars I want to display, based on if a user is logged in or not.

If they are not logged in, I’d like it to be:

  1. Home
  2. How It Works
  3. About Us
  4. Contact
  5. Login
  6. Sign up

If they are logged in, I’d like it to be:

  1. Report Symptoms
  2. Messages
  3. Results
  4. Profile
  5. Log out

I have tried conditions, but nothing has worked. I’ve also tried copying and pasting a different header per page, but there has to be a better way.

Would appreciate any insight, thank you!

These conditions are exactly for that purpose:
Screen Shot 2020-05-24 at 4.55.42 PM

2 Likes

@teamfaco15 just to be sure, are you using a RE for this?
You could then overlap two different groups in your RE (i.e. both versions of the header) and use conditions as SerPounce mentioned above. I don’t see why that wouldn’t work

@ambroisedlg Hi! I am not using a reusable element for the header since on my home page, I have it so once you click on…

  1. How It Works
  2. About Us
  3. Contact
  4. Login
  5. Sign up

…it scrolls the user down to that section on the home page. I was told doing the scrolling like this doesn’t work with a reusable element unfortunately.

Okay @teamfaco15, it should be pretty much the same config though. You can have a main group, inside of which you can include two groups (both versions of your header) and set the same conditions as SerPounce mentioned on each of the child groups:

  • If Current User is logged in -> this element is visible/is not visible
  • If Current User isn’ logged in -> this element is visible/is not visible

@ambroisedlg Okay, thank you! Do I do this for every page in the website, or just the home page…? I’m brand new to this and it’s not clicking easily, appreciate your replies!

@ambroisedlg


I currently have this, but when I preview the page I get this.

I followed the advice you both gave so I’m just wondering if I did something wrong!

@teamfaco15 no problem, what you did is called a workflow, not a condition. It does work but it’s not best practice.
Instead, in your Floating Group B’s config, go the conditions tab and define those two conditions:

  • when User is logged in -> this element is visible (checked)
  • when User isn’t logged in -> this element is visible (unchecked)

Do the same thing with opposite conditions for Floating Group A and it should work fine

You would need to setup these conditions on pages where you have those two different headers

@ambroisedlg THANK YOU SO MUCH! :heart_eyes:

1 Like

You’re welcome, glad I could be of help @teamfaco15

I have a similar use case but I am trying to use reusable elements to solve it.

I only want one header (RE), and I want a button in that header to show on my index page, but not on my other pages. Feels wrong to create “header A” and “header B” for this if I can help it…

I have edited the conditional properties of my button in the header – i.e. “When current page name is ‘index’ this element is visible” (and vice versa). Unfortunately the button either appears on both pages or disappears on both pages.

What am I doing wrong? I’m very new to this but am trying to lean into best practices with REs from the start – greatly appreciate your help!

I don’t see logged in as an option when I input the conditional?