Hiding Ticket Forms for Anonymous Users

8 Comments

  • Jennifer Rowe
    Comment actions Permalink

    Thanks for sharing this, Brandon!

    0
  • Heather Rommel
    Comment actions Permalink

    Brandon,

    This is great! Thank you! 

    0
  • Adam Fendelman
    Comment actions Permalink

    Thank you, but this is buggy. Sometimes it works where the form is hidden and sometimes it doesn't.

    Also, the directions are unclear. First, there isn't a JS tab. When you click Edit Code in your theme, there is a JS file (script.js). I tried the code many different ways and it only sometimes hides the form and sometimes doesn't. I don't think it's removing ticket fields. I think it's trying to remove the ticket form.

    Go to the JS tab, and add this near the top, here you're telling it to remove specific ticket fields from the drop down. Instead of 123, put in the actual ID of your ticket form. Put in everything but the ones you want to show for anonymous users.

    This is the code I'm using, where I'm including the three forms I want to show and excluding the one form I don't want to show. Am I doing something wrong?

    if (HelpCenter.user.role=="anonymous")
    {
    $('#request_issue_type_selectoption[value="360000684393"]').remove();
    $('#request_issue_type_selectoption[value="360000684413"]').remove();
    $('#request_issue_type_selectoption[value="360000690514"]').remove();
    $('.nesty-panel').on('DOMNodeInserted', function(e) {
    $(this).children('ul').children().remove('#360000684393');
    $(this).children('ul').children().remove('#360000684413');
    $(this).children('ul').children().remove('#360000690514');
    });
    }

    0
  • Brandon Kreines
    Comment actions Permalink

    Hi Adam, 

    Zendesk made some changes since I posted this, but yes you're right that script.js is where you want to be putting this. I've actually moved roles so I can't test anymore, but the code you posted looks right to me. One thing I want to make clear though is that the three forms you list there are the ones that it will HIDE. It will by default show everything and you only have to list the ones you want to hide. I wasn't sure from your wording if that's how you were doing it. Also you're right I made a typo in my original post, it should say "hide ticket forms" from users not "hide ticket fields"

     

    Not sure if that was helpful, but hopefully!

    0
  • Adam Fendelman
    Comment actions Permalink

    Ah, you said "Put in everything but the ones you want to show for anonymous users," so the three I included are the ones I want to SHOW. I just changed it to the below, which is the one I want to HIDE, but it doesn't work. The Creative Services Ticket Form should be hidden from here, but it's still there. Thoughts?

    if (HelpCenter.user.role=="anonymous")
    {
    $('#request_issue_type_selectoption[value="360000690494"]').remove();
    $('.nesty-panel').on('DOMNodeInserted', function(e) {
    $(this).children('ul').children().remove('#360000690494');
    });
    }

    0
  • Brandon Kreines
    Comment actions Permalink

    Oh! it needs to go inside the
    $(document).ready(function() { part or it won't work.

     

    Sorry my instructions had so many errors!

    0
  • Adam Fendelman
    Comment actions Permalink

    I just changed the position of my code block to be within that line. This seems to work now! Thank you! Does the Creative Services Ticket Form not appear for you in the drop-down here?

    0

Please sign in to leave a comment.

Powered by Zendesk