# How do I Hide Public pages from view on Login pages?

**URL:** <https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873>\
**Category:** Get Answers\
**Created:** [September 1, 2018, 4:10pm UTC](https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873 "2018-09-01T16:10:19Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnthonyPar64631](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@AnthonyPar64631](https://forums.knack.com/u/AnthonyPar64631)\
**Post date:** [September 1, 2018, 4:10pm UTC](https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873/1 "2018-09-01T16:10:19Z")

</div>

I have an app where 99% of it requires users to be logged in, BUT there are a few pages (Scene\_33,&nbsp; Scene34, & Scene\_36) that are embedded in a public site so their page tabs naturally show up on Login Pages even before users have logged in...

&nbsp;

Just for cleanness,&nbsp;I&nbsp;need a way to hide the page menu from just the login pages.&nbsp; Any ideas?

---

<div class="post-metadata">

**Author:** ![TonyRees](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@TonyRees](https://forums.knack.com/u/TonyRees)\
**Post date:** [September 3, 2018, 8:02am UTC](https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873/2 "2018-09-03T08:02:22Z")

</div>

Is this not what you are looking for:

[https://support.knack.com/hc/en-us/articles/225372267-Page-Menu-Videos-#hide-individual-links](https://support.knack.com/hc/en-us/articles/225372267-Page-Menu-Videos-#hide-individual-links)

---

<div class="post-metadata">

**Author:** ![TonyRees](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@TonyRees](https://forums.knack.com/u/TonyRees)\
**Post date:** [September 3, 2018, 8:00am UTC](https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873/3 "2018-09-03T08:00:23Z")

</div>

Is this not what you are looking for:

[https://support.knack.com/hc/en-us/articles/225372267-Page-Menu-Videos-#hide-individual-links](https://support.knack.com/hc/en-us/articles/225372267-Page-Menu-Videos-#hide-individual-links)

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [September 1, 2018, 4:34pm UTC](https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873/4 "2018-09-01T16:34:57Z")

</div>

Your welcome Anthony !

---

<div class="post-metadata">

**Author:** ![AnthonyPar64631](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@AnthonyPar64631](https://forums.knack.com/u/AnthonyPar64631)\
**Post date:** [September 1, 2018, 4:30pm UTC](https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873/5 "2018-09-01T16:30:44Z")

</div>

Works perfectly!&nbsp; You're a genius!&nbsp; Thank you!

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [September 1, 2018, 4:19pm UTC](https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873/6 "2018-09-01T16:19:03Z")

</div>

Hello Anthony,

try below code&nbsp;

$(document).on('knack-view-render.any', function (event, view, data) {  
 if(Knack.getUserAttributes()=="No user found")  
 $("#app-menu-container").hide();  
 else  
 $("#app-menu-container").show();  
});

if not work then you need to share your app with me or mail me&nbsp;

&nbsp;

Thanks,

Sunny Singla

[ssingla1985@gmail.com](mailto:ssingla1985@gmail.com)

+919855089359

---

<div class="post-metadata">

**Author:** ![Katelyn](https://avatars.discourse-cdn.com/v4/letter/k/3e96dc/32.png) [@Katelyn](https://forums.knack.com/u/Katelyn)\
**Post date:** [July 7, 2025, 1:07am UTC](https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873/7 "2025-07-07T01:07:54Z")

</div>

Hi Sunny or anyone. Please help a noob out. Two questions:

> [@Sunny\_Singla](#):
>
> $(document).on(‘knack-view-render.any’, function (event, view, data) {  
> if(Knack.getUserAttributes()==“No user found”)  
> $(“#app-menu-container”).hide();  
> else  
> $(“#app-menu-container”).show();  
> });

(1) This is CSS, right? Not Javascript?  
(2) Where do I enter the page I want to be hidden from the menu? What do I enter? The URL for the page?

I need this as a workaround to the fact that you cannot create “Rules” to hide content on public pages. I want a public “news” page and a members-only news page that contains the public articles and member-restricted articles. Of course I can create a separate members-only page, but then I need to hide the public page from the main menu when the user is logged in. Thank you!

---

<div class="post-metadata">

**Author:** ![StephenChapman](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/stephenchapman/32/1759_2.png) [@StephenChapman](https://forums.knack.com/u/StephenChapman)\
**Post date:** [July 7, 2025, 3:01am UTC](https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873/8 "2025-07-07T03:01:37Z")

</div>

Hi @Katelyn,

Here’s a solution specific to your needs:

1. Create a public **Articles** page (`scene_xx`)
2. Create a login-protected **Member Articles** page with URL ‘_member-articles_’, and hide it in the page menu
3. Add this code to your **Knack JavaScript** editor, replacing `scene_xx` with your public page scene key, and change the `member-articles` URL slug if need be.

```auto
Knack.router.on('route:viewScene', function(slug, search) {

  const currentScene = Knack.getCurrentScene();
  var sceneKey = Knack.scenes.getBySlug(currentScene.slug)?.get('key');
  if (sceneKey === 'scene_xx' && Knack.getUserAttributes()?.id) {
    window.location.href = '#member-articles';
  }

});

```

Whenever someone visits your **Articles** page, this code will check if that user is logged in, and if so, will redirect them to the **Member Articles** page immediately. If they aren’t logged in, they will remain on the Articles page.

You might also want to put a friendly link on the public **Articles** page which says something like: '_Already a member? Click here to login’_, linking to the **Member Articles** page.

Hope that’s useful!

---

<div class="post-metadata">

**Author:** ![Katelyn](https://avatars.discourse-cdn.com/v4/letter/k/3e96dc/32.png) [@Katelyn](https://forums.knack.com/u/Katelyn)\
**Post date:** [July 10, 2025, 1:43am UTC](https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873/9 "2025-07-10T01:43:08Z")

</div>

This is perfect, thank you Stephen!

---

<div class="post-metadata">

**Author:** ![Katelyn](https://avatars.discourse-cdn.com/v4/letter/k/3e96dc/32.png) [@Katelyn](https://forums.knack.com/u/Katelyn)\
**Post date:** [July 10, 2025, 1:52am UTC](https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873/10 "2025-07-10T01:52:22Z")

</div>

Maybe one more related question . . . I have a “log in” button in the top main menu that links to a login page. I want this hidden when the user is logged in, or I want to change its text (to the actual title of the login page). Any ideas?

---

<div class="post-metadata">

**Author:** ![Katelyn](https://avatars.discourse-cdn.com/v4/letter/k/3e96dc/32.png) [@Katelyn](https://forums.knack.com/u/Katelyn)\
**Post date:** [July 14, 2025, 1:49am UTC](https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873/11 "2025-07-14T01:49:23Z")

</div>

> [@Katelyn](#):
>
> I have a “log in” button in the top main menu that links to a login page. I want this hidden when the user is logged in, or I want to change its text (to the actual title of the login page). Any ideas?

Any ideas on this? This is more in line with the original subject of this page.

---

<div class="post-metadata">

**Author:** ![StephenChapman](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/stephenchapman/32/1759_2.png) [@StephenChapman](https://forums.knack.com/u/StephenChapman)\
**Post date:** [July 14, 2025, 9:27pm UTC](https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873/12 "2025-07-14T21:27:37Z")

</div>

Hi @Katelyn, I’d recommend you have a menu link on your public page rather than in the header menu, which links to the login-protected page:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/3/38bd6e9bab6d6c5991e282939e45e78c0868e883.png)

A coded approach relies on hard-coding the original content in the link, as well as ensuring that all logged-in/non-logged in users can see all links regardless of role by ensuring the below setting is unchecked:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/9/9ca07a077f244788dac35619b709794644c015fa.png)

If you still feel strongly about this, here is some code:

- Replace `#projects` with your scene URL
- Replace `fa fa-briefcase` with your menu link icon, and `Projects` with your menu link title

```jsx
$(document).on('knack-view-render.any', function (event, view, records) {

  const $menuLink = $('.knHeader__menu-link[href*="#projects"]');
  const linkContent = `<span class="knHeader __menu-link-icon knHeader__ menu-link-icon--left"><i class="fa fa-briefcase"></i></span> Projects`

  if (Knack.getUserAttributes()?.id) {
    $menuLink.html(linkContent);
  } else {
    $menuLink.html('Login');
  }

});

```

**How it works:**

- Every time a view render on a page, it will determine if the user is logged in.
- If the user is not logged in, it will change the specified link text to ‘Login’.
- If the user is logged in, it will set the specified link text to its default.

---

<div class="post-metadata">

**Author:** ![Katelyn](https://avatars.discourse-cdn.com/v4/letter/k/3e96dc/32.png) [@Katelyn](https://forums.knack.com/u/Katelyn)\
**Post date:** [July 17, 2025, 1:53am UTC](https://forums.knack.com/t/how-do-i-hide-public-pages-from-view-on-login-pages/9873/13 "2025-07-17T01:53:27Z")

</div>

Thank you for the suggestions.
