Adding a button to an external site to our Help Center, with restrictions?

Answered

3 Comments

  • Karen D Snyder

    Iris Corenevsky

    It depends on how you want to restrict access, and how your users sign in. If only your employees would be signed in, and non-employees wouldn't be signed in, you could use the helper {{#if signed_in}}, and put something like this in the template(s) where you want the button, where you replace [external site URL] with the link to the external site:

    {{#if signed_in}}
    <div class="myExternalLinkClass">
    <a href="[external site URL]"></a>
    </div>
    {{/if}}

    If non-employees and employees would be signed in, then that helper won't work for you. In that case, you could use custom code in script.js to restrict access to the link, using the HelpCenter object that contains the user's name, email, role, groups, organizations, and tags. So then you would put the above code without the signed_in helper in the template(s) where you want the button.

    Then, for instance, assuming that all your employees belong to the same organization so that you could restrict based on organization, you would put the following code in script.js inside the document.ready function, replacing myOrganization with the name of the organization, spelled exactly and with the correct capitalization, because the includes function is case-sensitive:

     if (!(HelpCenter.user.organizations.map(function (x) { return x.name }).includes("myOrganization"))) {
       $('.myExternalLinkClass').remove();
    }

    The above code checks if myOrganization is in the user's organizations; if not, it removes the element containing the link. 

    I have not included information on the CSS for the link, as I don't know if you need help with that.

    If you need further clarification or help. please let me know.

    1
  • Dan Ross
    Community Moderator

    Hey Iris,

    There's a document that I found to be useful as well found here, that covers restricting HTML depending on the user's role, very helpful if you have a mixed help centre environment with agents and end users.  Karen's solution above is the best one however, as it removes the element, rather than hiding it.  Hidden elements can be shown by someone who knows how to use browser dev tools, but removed ones can't. 

     

     

    1
  • Iris Corenevsky

    Thank you, Karen D Snyder and Dan Ross! Karen, your suggestion looks to be working. Appreciate the assist!

    0

Please sign in to leave a comment.

Powered by Zendesk