Recent searches


No recent searches

Allow only signed-in users to submit a ticket



Posted Jun 30, 2016

Zendesk note: This tip is addresses the use case where you want to hide the submit a request link until the user signs in, and not restrict tickets in all channels to sign-in users. Alternatively, you can restrict all ticket submission to signed-in users, and prompt users in the Help Center to sign in when they click submit a request (see this article).

Problem: Many organization having their HC on public URL want's the ability to have only signed-in users (end users) to have access to submit a ticket page (new request page).

Solution: Using the below code you can prompt the user to sign-in/signup in order to send a ticket. Zendesk note: Instead of using the JSS in this tip, you might consider using the signed-in helper as described in this comment and the subsequent comment.

  • Login into your Help center as admin/agent
  • Click customize design
  • Click Edit theme
  • On HTML replace the submit a request component by adding class=“request” to the element you want to wrap submit-a-request button.
  • For an e.g. see how below screen

  • Now go to JS and paste the below code:
 (function(_w, _d, $){

$(_d).ready(function(){
var _locale = window.location.pathname.replace('/', '')
.replace('?','/').split('/')[1];
if (HelpCenter.user.role=='end_user') {
$('.request')
.html('<a class="submit-a-request" href="/hc/'+
_locale+'/requests/new">'+
'Submit a request</a>');
} else if (HelpCenter.user.role=='anonymous') {
$('.request')
.html('<a href="/hc/'+
_locale+'/signin">'+
'Submit a request</a>');
}
});

}(window, document, jQuery));


  • Save and publish the changes.

This would ask your non-logged in user to sign-in/sign-up if they want to submit a ticket on your public help center.

Get its touch (support@diziana.com) if you face any problem.

Cheers,

Diziana


0

11

11 comments

Hi Diziana, this is really useful thank you! It works that when the anon user selects the submit a request link it brings up the sign in/sign up screen. How can I apply the same logic to the mobile layout? 

How can I apply the same logic to the mobile layout? The submit a request brings up the submit a request form which I don't want. 

Many thanks, 

Annastashia

0


Hi Annastashia,

Thanks for reaching out to us. I think this should work. Did you disable the mobile layout from the HC settings? 

I looked at your HC and it seems you haven't disabled the mobile layout option, please disable it.

Also on responsive you need to add the submit button on the menu (hamburger icon) as for now only sign in seems to be listing.

Please share if you have further any questions.

Looking forward hearing from you.

Cheers,

Diziana

0


image avatar

Jake Bantz

Zendesk Product Manager

Thanks for the tip Diziana.

I did want to advertise that we now have some built in functionality to allow you to check if a user has signed in. Here's the sample code:

{{#if signed_in}}
{{link 'new_request'}}
{{/if}}

You can read more about the 'signed_in' helper here. This removes the need for Javascript, and instead the user will get the page without the submit a request link right away if they are not authenticated.

Hope this is helpful!

0


image avatar

Jennifer Rowe

Zendesk Documentation Team

Oh, that's good to know. Thanks, Jake.

0


Zendesk - that's a good workaround for hiding the links from end-users, but that does not prevent them from using:

https://{{base_url}}/hc/en-us/requests/new

to get around it. 

Is there a config setting or strategy that would not allow users to log a request unless logged in?

Cheers,

Bob

Update - I used in the new_request_page.hbs so that seems to prevent anyone from invoking the https://{{base_url}}/hc/en-us/requests/new on the URL.

{{#if signed_in}}
...
{{/if}}

0


image avatar

Jake Bantz

Zendesk Product Manager

You hit the nail on the head Robert! Wrapping the signed in condition around the ticket form will hide it for anonymous users as well. You could even include a message as an alternative (using an 'else' condition) like this:

{{#if signed_in}}
<h1>
{{t 'submit_a_request'}}
{{#if follow_up}}
<span class="follow-up-hint">
{{follow_up}}
</span>
{{/if}}
</h1>
<div class="form">
{{request_form}}
</div>
{{else}}
<h3>Please sign in to submit a ticket.</h3>
{{/if}}

This is from the default Copenhagen theme, so yours might look a little different, but I hope this helps.

0


Hi Jake, what if i want to hide the submit request even for sign-in user, but embed the ticket form link at the article (which will prompt for user to sign in with above use of signed_in condition)

0


image avatar

Jake Bantz

Zendesk Product Manager

Hello!

First, I would recommend removing the request placeholder from the Header template since you don't want it to appear for any users.

Next, know that our default Copenhagen theme has a request callout in its article_page.hbs template that looks like this:

Here's the associated code:

<div class="article-more-questions">
{{request_callout}}
</div>

You could recycle my tip above, but instead wrap that around the request_callout:

{{#if signed_in}}
{{request_callout}}
{{else}}
Please sign in to submit a request.
{{/if}}

Hope that helps!

0


Hi Jake. Thx for the article! it is super helpful. We would like to show the "submit a request" form for registered users only, however for the unregistered ones, we would like to show an alternative short submission form. how would we do that?

1


@...

My organization does not use multiple forms but to achieve what you are looking for, I would use the "else" portion of this tip and follow the instructions from @... post here https://support.zendesk.com/hc/en-us/articles/206977397-Multibrand-Display-the-appropriate-forms-on-the-correct-Help-Center 

There is a section called "Displaying one form per brand"

@... also, provides a way to redirect users and edit other links in the comments of that post. https://support.zendesk.com/hc/en-us/articles/206977397/comments/204904167

0


image avatar

Jahn

Zendesk LuminaryCommunity Moderator

You can also use the below code under script.js to let anonymous users to sign-in to the Help Center once they click the “Submit a request” button. By doing this we won't be removing the Submit a request button in our Public Help Center but customers can only submit tickets when they are logged in.

$(document).ready(function() {
   // Function to check if the user is signed in
   function isUserSignedIn() {
       return typeof HelpCenter.user !== 'undefined' && HelpCenter.user.role !== 'anonymous';
   }

   // Attach the click event handler to the "Submit a request" button
   $('a[href="/hc/en-us/requests/new"]').click(function(event) {
       if (!isUserSignedIn()) {
           event.preventDefault();
           window.location.href = '/hc/en-us/signin'; // Redirect to the login page
       }
   });
});

Note: Ensure the selector 'a[href="/hc/en-us/requests/new"]' matches the actual URL used in your Help Center for the "Submit a request" button. Adjust the selector if the URL is different.

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post