Skip to main content
Solved

Customize visibility of homepage widgets

  • April 13, 2023
  • 1 reply
  • 67 views

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? 

Best answer by DannyPancratz

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>

 

View original
Did you find this topic helpful?

1 reply

DannyPancratz
Forum|alt.badge.img+7
  • VIP ⭐️⭐️⭐️⭐️⭐️
  • 966 replies
  • Answer
  • April 13, 2023

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>

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings