Tip: How to Show/Hide HTML content based on user tags

5 Commentaires

  • Alejandro Colon

    Great article. One thing I would suggest though is to use vanilla javascript so that all Guide admins can use your post. Currently, Guide templates "v2" do not use jQuery, which would cause the code to not work. 

    0
  • Jordan Dayton

    Thanks for chiming in here @.... What exactly should I change? I'm happy to make any updates that makes this usable for others. This code is working well for me.

    (Though I did notice one issue... when I visit the page with this code on it, everything displays, as expected... only to those who have a certain TAG associated with their account. If I hit the "Refresh" button on the page, the custom code bit disappears... even if you're a user with the "ticket-access" tag. Any ideas on how to address/debug that?)

    0
  • Alejandro Colon

    I am not sure what is going on with the page refresh. It might have something to do with caching or your code is not running on subsequent page refreshes. I would have to try and replicate it myself. Maybe someone with more knowledge can help out with that. 

    As for the code changes, it should be as simple as the following:

     

    Replace 

    $("div.ticket-access").show();

    With

    document.querySelector('.ticket-access').style.display = "revert";

     

    Replace

    $("div.org-access").show();

    With

    document.querySelector('.org-access').style.display = "revert";

     

    Let me know if that doesn't work but it should.

    0
  • Adam Mark

    This is just awesome :)

    0
  • Morgan King

    Has anyone ran into this not working on Theme version 2.9 even after the above replacements in the previous comments suggest?

    0

Vous devez vous connecter pour laisser un commentaire.

Réalisé par Zendesk