Redirect homepage to My Activities page upon login.

Respondida

3 Comentarios

  • Socorro Fernandez

    Hi Amie,

    I believe I was able to get a script to work as you described but I ended up placing the following code at the very end of home_page.hbs :

    <script>
    $(document).ready(function() {
    if ((HelpCenter.user.role=="end_user")||(HelpCenter.user.role=="anonymous")) {
    $(window.location.replace("https://YOURDOMAINHERE.zendesk.com/hc/requests"));
    }
    });
    </script>

    I originally put this is script in the JS file but it continued to reload the page since I didnt have another condition to compare the current page and to not run the script. I decide to put the above code on the home_page.hbs which fixed the issue since it will only run if a user goes to the homepage.

    Please let me know if you have any questions or if you run into anything with this.

    Thanks!

    0
  • Sushant Awalekar
    Community Moderator

    Hi Amie,

    I have tested the same code snippet in my helpcenter and its working as expected.So Can you provide more details on where you have added this code in script.js ? 

    0
  • Chris Cheung

    HI, i'm trying to do the same thing.  I redirect the login page to go to My Activities if already signed in.  Or we will take them to a different login page if not signed in.  But, if logged in, I don't want a "flash" of the default zendesk login page. 

    The issue is that we have styled the page with our logo.  This appears as an odd "wrong looking" splash page while the redirect happens.

    I have my redirect code (below) in the "document_head.hbs" which should be in the <head></head> tag. This should fire before anything on the body renders and redirect to the page we want. But still, a flash of the login screen appears.

    I think I'll try putting in some javascript to edit the CSS, like disappear the logo if you're on the login page. Anyone else run into this?

    <script>
    if (window.location.pathname === "/hc/en-us") {
    {{#if signed_in}}
    location.href="/hc/en-us/requests";
    {{/if}}
    }


    </script>

    0

Iniciar sesión para dejar un comentario.

Tecnología de Zendesk