Hiding Ticket Forms for Anonymous Users

11 Commentaires

  • Jennifer Rowe
    Zendesk Documentation Team

    Thanks for sharing this, Brandon!

    0
  • Heather Rommel
    Community Moderator

    Brandon,

    This is great! Thank you! 

    0
  • Adam Fendelman

    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

    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

    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

    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

    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
  • Dawn Anderson

    Hi

     

    I'm new to coding and need some help, when you say it needs to go inside the below - is this within the brackets of function?

    $(document).ready(function() { 

    0
  • Dawn Anderson

    Hi

     

    Sorry, another question! When I add this in it's bringing me to a log in screen? Would the roly end-user be same as anonymous? If so, what would I need to enter as end user please?

     

    Regards

    0
  • Erika Camille Sundian
    Zendesk Community Team

    Hello Dawn,

    I would like to share the following documentation which will give you more control of the feature involved in the task you may wish to accomplish

    This will provide a new level of control over your platform and can help you implement the desired workflow.

    If you decide to take this course of action please consider applying the adjustments with the help of a web-developer to ensure proper execution, our support in this kind of case is limited given the fact that these modifications entail modifying the base code there is to the Zendesk platform.

    0

Vous devez vous connecter pour laisser un commentaire.

Réalisé par Zendesk