Configure a block to be visible for visitors but not logged in user

Is it possible to configure a block so that it is visible for visitors but when they log in it will be hidden? If so, how do I accomplish that?

I guess I need to set up groups and permissions correct but cannot find information, for examples of how to use the different templates on the groups and what they mean or what _everybody is or if there is other users like that.

Litium version: 8.20.0

You can check if a customer is signed in or not (anonymous) like this.

var isAnonymousUser = !_securityContextService.GetIdentityUserSystemId().HasValue;

We’ve built a block that can have nested blocks. The nested blocks are only populated and displayed if the customer is an anonymous (not signed in) user.

Hey Mattias!

I built this in my last project at Columbus for a certain customer, so you could take a look at that code. Thomas was project manager.

Unless it is already that project you are talking about and its not working as it should :wink:

However Samuels solution sounds cleaner, I did not think of nested blocks at the time.

/Martin

Hi Martin!

Yes, I found how you did it on the other customer which is quite clear. And Samuel gave another solution. :grinning_face: I was hoping for a solution that didn’t involve coding but it seems that I can’t get that but now I know.

Thanks for your help.
//Mattias

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.