Recent searches


No recent searches

Hiding a ticket form from anonymous users

Answered


Posted Jan 09, 2023

Is there a way to restrict a specific ticket form from being visible to anonymous users i.e. Help Center visitors who are not signed in? We have different personas accessing our public Help Center and ideally, this specific form is not available from the drop-down field on the new request page unless they're signed in. 

I've seen the other Community posts where you can restrict form viewing permissions based on the organization name or user tags, and how you can restrict the "submit a request" button entirely, but unfortunately, none of these existing posts solve this specific use case. 


1

9

9 comments

image avatar

Pulkit Pandey

Zendesk LuminaryCommunity Moderator

Hi Grace Mun

Please, add the below code at the bottom of your script.js file 

  function DisableSubmitaRequestbutton(){
    if (HelpCenter.user.role=="anonymous"){
      document.querySelector(".submit-a-request").classList.add("hide");
        }
  }
  DisableSubmitaRequestbutton();

Let me know if it solves your issue 

Thank You

Pulkit

Team Diziana

0


Hey Pulkit Pandey, would this code block anonymous users from submitting a request in general? 

We still want anonymous users to be able to submit a request, there's just a specific form we want to hide from them. 

I've set up the code below and it seems to work actually:

//To hide a form from anonymous users
jQuery( document ).ready(function() {
if (HelpCenter.user.role=="anonymous"){
var tagsToRemove = ['insert form ID'];  
function removeTagsWeDontWant() {
$('.nesty-panel').on('DOMNodeInserted', function(e){
for(var i in tagsToRemove) {
$('li#' + tagsToRemove[i]).remove();
}
});
};
removeTagsWeDontWant();
}
})

1


We want to hide 9 of 10 forms from anonymous users. What is the syntax to list multiple form IDs in this code?

Thanks in advance! This is a beautiful thing.

0


image avatar

Zsa Trias

Zendesk Customer Care

Hello Mark,

The custom code seems to be provided by one of our community members. 
I have implemented the same code on my test account, adding multiple form IDs thru this line:

var tagsToRemove = ['formID1', 'formID2', 'formID3']; 

However, please do note, we're unable to guarantee that it will continue to function as the product changes.

0


Thank you for the assist. I will use it gladly for as long as I can.

0


Would the jquery referenced above go in the script.js file or on the new request page? I added the script to the script.js file, adjusted for multiple forms to block from anonymous sight, and published it, and I don't see that it's working.

0


Never mind! I forgot to add the jquery script to the document_head file.

https://support.zendesk.com/hc/en-us/articles/4408829274906-Importing-or-upgrading-jQuery

0


image avatar

Zsa Trias

Zendesk Customer Care

Awesome! Glad you're able to figure this out, Mark!

0


This has stopped working for me and I can't tell if changes to Zendesk have broken it. I'm using the Diziana Makem theme, Theme version 3.1.2, Templating API v1. I've added jQuery 3.6.1 to the script.js file, made sure the form IDs below are correct, and added the following code to my document_head file:

//Hide forms from anonymous users
jQuery( document ).ready(function()  {
if (HelpCenter.user.role=="anonymous"){
var tagsToRemove = ['1260815258330', '1900004317724', '13506320793243', '1260815256470', '1900004317704', '13528765623707', '5308706681371', '5073802798235', '1260815252470', '1900004315784', '17932684959515', '17932846343067', '17932966253339', '18224882477211', '17932893585691'];  
function removeTagsWeDontWant() {
$('.nesty-panel').on('DOMNodeInserted', function(e){
for(var i in tagsToRemove) {
$('li#' + tagsToRemove[i]).remove();
}
});
};
removeTagsWeDontWant();
}
}
);

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post