I'm having trouble hiding my login and registration links when a user is logged in.

Shane Cao asked on August 22, 2018 16:49

I'm using the Signout button webpart which works great. The issue I am having is since I added a login and registration link to my navbar I'm not quite sure how to hide those when a user is logged in. I attempted to do javascript but can't seem to return if the user is logged in, any ideas?

this is my navbar Image Text

or you can view it here https://imgur.com/pHFF4Cr

the javascript code I am trying to do to hide the login and contact button looks like this;

$(document).ready(function(){
var is_user_logged_in = <% CMS.CMSHelper.SessionManager.GetUserId() %>

if(is_user_logged_in)
{
    document.getElementById('.user-auth').hide();
}
});

and it keeps saying I need a ';' after the CMS part.

Correct Answer

Peter Mogilnitski answered on August 22, 2018 17:05

No need for javascript here. First of all check the Visibility and Display settings for the web part. For logon web part you set visibility based on roles

1 votesVote for this answer Unmark Correct answer

Recent Answers


Shane Cao answered on August 22, 2018 16:52 (last edited on August 22, 2018 16:52)

0 votesVote for this answer Mark as a Correct answer

Shane Cao answered on August 22, 2018 17:10 (last edited on August 22, 2018 17:16)

Thank you for responding so quickly Peter. I am working with kentico 11 and I don't see a logon web part to use in the Web part content list. My login and Join Us button are in the navbar of my master template. and the Signout button is the SignoutButton webpart which shows up if the user is logged in.

This is all I see in the list https://imgur.com/a/ZLtyU4R

ACtually I see how to do it now, I went about it all wrong! I made an entire new pate for login with isnt needed. Thanks so much!

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on August 22, 2018 17:16 (last edited on August 22, 2018 17:21)

Logon Mini Form is the web part that you would normally use in your web site menu. it is #8 on your picture. Normally you would use 3 web parts here:

  1. Logon Mini Form
  2. Current User
  3. Sign out button

I suggest to install Kentico example sites like Corporate site and see how it is done there.

0 votesVote for this answer Mark as a Correct answer

Shane Cao answered on August 22, 2018 17:37

Thanks peter this is helpful. I was wondering if there was a way to make the input boxes be horizontal on one row within the web part or will i need to do some of my own css for that?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.