Skip to main content
Contributor ⭐️
Apr 13, 2023 5:48 PM UTC
Solved

Customize visibility of homepage widgets

I have an HTML widget that is public to anyone who visits the community home page.  I want to make it visible only to members who are logged into the community. It’d be even better if I could make it visible only to a specific user role. Is there a way to do this? 

DannyPancratz
VIP ⭐️⭐️⭐️⭐️⭐️
Apr 13, 2023 6:09 PM UTC

Yes, I did this with the help of support. 

You use this third party script in the Before </body> section.

<script>
  
 if (inSidedData.user.role == 'roles.guest') {
    document.getElementById('name of your widget').style.display = "none";
 }
 
</script>

 

For that to work, you need to name your widget in the HTML in the front end HTML widget setup to work 

<div id="name of your widget">

the rest of your html code

</div>

 

FYI: I am no longer active in this community

1 reply

DannyPancratz
VIP ⭐️⭐️⭐️⭐️⭐️
Apr 13, 2023 6:09 PM UTC

Yes, I did this with the help of support. 

You use this third party script in the Before </body> section.

<script>
  
 if (inSidedData.user.role == 'roles.guest') {
    document.getElementById('name of your widget').style.display = "none";
 }
 
</script>

 

For that to work, you need to name your widget in the HTML in the front end HTML widget setup to work 

<div id="name of your widget">

the rest of your html code

</div>

 

Translate
FYI: I am no longer active in this community