Help Limiting Content Based on User Segment
AnsweredI am wanting to limit specific content on the homepage based on user segment.
I do this based on tags in a different area by using this javascript:
var userTags=HelpCenter.user.tags;
//check if any tags are returned. If no tags defined, print to console.
if (userTags.length!=0)
{
//if tags are found, start iterating through using a for loop.
for(var i = 0; i < userTags.length; i++ )
{
//check for the require tag.
if (userTags[i] === 'emergencycontact')
{
//unhide link
$('div.emergencylink').show();
$('div.nopostrights').hide();
}
}
}
});
Anyone have thoughts on how I can achieve something similar for an organization or user segment? I really don't want to manually tag 325 users.
-
Hi Morgan King,
You can use the same code replacing HelpCenter.user.tags with HelpCenter.user.organizations and check for the organization instead of tags.
Currently, there is no way to do this using Zendesk HelpCenter Components so one has to use the JS code in order to achieve something like this.
Let me know if this solves your issue.
Thanks
-
Thank you, Trapta!! That did it.
-
Perhaps someone could help on this? For HelpCenter.user.organizations[0].name, it will only break the js if there is no organization that a user belongs to. I've tried all sorts of looking for length like the above example and it breaks when a user does not have an organization. Any help would be appreciated.
Thanks so much.
- Michael
-
Hey Michael,
It looks like you haven't received a response on this post. I'm rather limited on what I can assist with from my end, but I did want to double-check with you to see if you're still running into the same issue.
If so, any chance you could provide the code you're using so far? This may help other community members get a better understanding so they can assist further.
Thanks!
Please sign in to leave a comment.
4 Comments