How can I hide or show HTML based on user's role or group?

Return to top
Have more questions? Submit a request

37 Comments

  • Jeremy Robinson
    Community Moderator

    Aaron - one last bit, that we did when we went through a user tag phase for our beta rollout of the community aspect in Zendesk was the bulk update with CSV for users, that way we didn't have to manually go in and update one at a time. 

    0
  • Brett Bowser
    Zendesk Community Team

    Thanks for sharing this solution Jeremy!

    1
  • Jean-Baptiste Hennion

    Hello ! This oslution seems to not work anymore with the new template version !

     

    https://support.zendesk.com/hc/en-us/articles/360043187273#topic_llb_t5g_skb__section_rxc_dbd_tkb

    0
  • Simon Agliati

    Does anyone know how to show/hide based on a users role by using Curlybars if statements? Is this possible?

    0
  • Kay
    Community Moderator

    Simon Agliati the only way to do that is documented above here.

    // Show div html based on role
    if (HelpCenter.user.role=="anonymous"){
    $("div.anonymous").show();
    }

    if (HelpCenter.user.role=="end_user"){
    $("div.end_user").show();
    }

    if (HelpCenter.user.role=="agent"){
    $("div.agent").show();
    }

    if (HelpCenter.user.role=="manager"){
    $("div.manager").show();
    }
    0
  • Ron de Vries

    Hello! 

    Does anyone have any experience or knowhow how to show the Community for a specific User Segment only? I have a User Segment ''Staff'' which are the employees or our company. Since we first want to roll-out the Community internal I am looking for a way to have it shown only to that specific User Segment. I do think the User Segment has an ID, maybe I can target that using JavaScript?

    Any help is much appreciated. Thanks and have a great New Year!

    Ron

    0
  • Nicole S.
    Zendesk Community Team

    Hi Ron, 

    All you need to do is set the visibility of all of the topics in your community to that internal user segment. 

    You may need to hide the link to the community from en-users on your Help Center with a little custom code, otherwise they'll click it and show up to an empty community. Then just make sure you give your employees a direct link to the community as they won't be able to navigate to it. 

    0

Please sign in to leave a comment.

Powered by Zendesk