Pesquisas recentes
Sem pesquisas recentes
Restrict Web Widget to Certain Users?
Publicado 20 de mar. de 2025
Hello, I am trying to restrict the web widget to only appear for users with the user tag “administrator” and it does not appear to be working.
I am repurposing one suggested for organizations: https://support.zendesk.com/hc/en-us/articles/4408820799130/comments/4967400163482
for (var c in HelpCenter.user) {
if (HelpCenter.user[c].tags.includes("administrator")){
zE('messenger', 'show');}
else
{zE('messenger', 'hide');}}
0
1
1 comentário
Rose Scott
Hey there! It sounds like you're diving into some custom widget logic, which is pretty cool. Let's see if we can get this working for you.
Looking at the code snippet you've shared, it seems like you're trying to iterate through properties of the
HelpCenter.user
object. However,HelpCenter.user
isn't structured as an array or an object you can directly loop through with afor...in
loop like that to access user details E-ZPassMDTypically, the user information, including tags, is directly accessible within the
HelpCenter
object. You can usually check the tags like this:JavaScript
Here's a breakdown of why this might work better:
HelpCenter.user.tags
: This directly accesses thetags
property of theHelpCenter.user
object. It's likely that the tags are stored as an array here.&&
(Logical AND): We first check ifHelpCenter.user.tags
exists (is not null or undefined) before trying to use theincludes()
method. This prevents potential errors if a user doesn't have any tags..includes("administrator")
: This array method checks if the string "administrator" exists within theHelpCenter.user.tags
array.Where to put this code:
You'll typically place this JavaScript code within your Help Center's theme. The exact location might depend on your theme, but common places include:
<script>
tags in these template files.0
Entrar para comentar.