skip to Main Content

By default when a user logs in GHL, he is sent to "/dashboard" by default. But I want the user to redirect to Contacts page instead –> "contacts/smart_list/All". GHL allows custom JavaScript, so I came up with the following script:

But it only works if I am on the "/dashboard" page already and refresh it manually.

I want this to work right after the user logs in and when dashboard is loading, the script should be loaded and do its work and redirects the user to "contacts/smart_list/All" page instead.

I know this is possible as other people have done it, but I don’t know what I am doing wrong.

<script> if (window.location.href.match("location/xkTaFgTklXH0jB/dashboard")) { window.location = "https://app.gohighlevel.com/v2/location/xkTaFgTklXH0jB/contacts/smart_list/All"; } </script>

2

Answers


  1. You can do like this:

    document.addEventListener('DOMContentLoaded', function() {
        if (window.location.href.includes("/dashboard")) {
            window.location.href = "https://app.gohighlevel.com/v2/location/xkTaFgTklXH0jB/contacts/smart_list/All";
        }
    });
    
    Login or Signup to reply.
  2. Your provided script is comparing if current url is dashborad then only redirect to contacts/smart_list/All url

    <script>
        // redirect if the current page is dashboard
        if (window.location.href.match("location/xkTaFgTklXH0jB/dashboard")) {
            window.location = "https://app.gohighlevel.com/v2/location/xkTaFgTklXH0jB/contacts/smart_list/All";
        }
    </script>
    

    But your requirement is something like you have to add script to login page which will check the user is sinned in or not

    If Signed-In success then redirect to the https://app.gohighlevel.com/v2/location/xkTaFgTklXH0jB/contacts/smart_list/All

    
    <script>
        // Check if the user is logged in (you need to replace this with your actual check)
        const userIsLoggedIn = true /* Replace this with your logic to check if the user is logged in */;
        if (userIsLoggedIn) {
            // If the user is logged in, redirect to the desired page
            window.location.href = 'https://app.gohighlevel.com/v2/location/xkTaFgTklXH0jB/contacts/smart_list/All';
        } else {
            window.location.href = '/login'; // Replace '/login' with the actual login page URL
        }
    </script>
    
    

    That’s it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search