Skip to main content

Hello,

 

We have a custom page for a specific subset of users. Within the custom page, we have quick links to sub categories. Depending on the users role we want them to only see certain quick links on this custom page.

 

Note: If we use the Category widget instead of quick links, all other categories they are a part of, outside of this Custom page, will be visible on this custom page so I am also open to solutions that allow me to hide categories on a custom page. 

 

Is there any way to set this up?

Hi @lyoung - right now the only way to only show certain elements to a segment of users defined by a custom role is to use third-party script, CSS and the ‘inSided dataObject’.  You’d need to create a custom set of ‘quick links’ in an HTML widget instead of using the native widget.  We have a number of topics about how to do that in this community, for example here:

 


I do something like that for a row of Quick Links I only show to logged-in users. Here’s the script for Insert Before /Body section of Third Party Scripts. 

<script>
var roles = window.inSidedData.user.role;
if (inSidedData.user.role == 'roles.guest') {
document.querySelector("#root > div.widget-container.widget-container--quick_links.widget-container--index-7 > div > div > section > div > div").style.display = 'none';
}
</script>

You’ll need to use the Inspect tab to target the right quick links widget. It’ll depend on where it’s located on the page (that changes the index number). And be careful if you use quick links widgets in the same place on other customizable pages, this may impact those as well. 

Use case: Quick Links showing for only logged-in users

 

And here’s a script I used for a row of quick links for only users in an Early Access Program (EAP). This one is based on a custom user role, not primary user role. 

<script>
var roles = window.inSidedData.user.role;
if(!inSidedData.user.role.includes('EAP'))
{
document.querySelector("body > main > div.homepage-widget-container.widget-container.homepage-widget-container--quick_links.widget-container--quick_links.homepage-widget-container--quick_links.widget-container--quick_links.homepage-widget-container--index-8.widget-container--index-8 > div > div > section").style.display = 'none';
}
</script>

 

Support helped me with both of these. 


Ahh thanks @DannyPancratz - I’ve only ever done this with custom HTML widgets, but seeing this it makes sense that we can also target the native quicklink widgets.  Awesome clarification.  


Thank you both for your responses.

We’ll need to hide individual quick links for specific custom roles so I don’t think hiding an entire row will work - plus the fact that we use custom pages a decent amount so I don’t want to inadvertently hide them for another page but between both of your suggestions I might be able to work something out. 

I really appreciate the quick and thoughtful help!


Yeah, that’s going to be much harder. 

(I’m not an expert on this, but) I took a quick look and it appears you can isolate individual quick links in the widget. However, the JS Path you’d use to target it includes the same risk of applying that settings to the quick links widget on other pages. 

At one point, the ability to customize who sees widgets by role was on the road map. If/when that’s delivered, this will get easier, but still doesn’t solve what you need. However, in that scenario you could do something like X different versions of the same widget with permissions to show the right one to the right user roles. 

Until then, it’d be much easier to replicate as a series of HTML widgets on a side bar. If a vertical layout would work for the same tiles, you could do each “quick link” as an HTML widget and then have settings to display/hide for users. 


Reply