Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 5e1c260be2sEO3hyKAP+oI
Power Pages - Power Apps Portals
Answered

Redirect to Specific Page after Login

Like (0) ShareShare
ReportReport
Posted on 16 Dec 2021 04:26:01 by 1,510

Hi,

 

Once user sign in using local sign in or Azure AD, user must redirect to specific page.

  • H V Profile Picture
    1,510 on 21 Dec 2021 at 05:16:33
    Re: Redirect to Specific Page after Login

    Thanks @ragavanrajan 

     

    I have tried above code and it is working.

    So, If I put below code in Home - Localized Content Web Page and it is working fine.

    $( document ).ready(function() {
     var userData = "{{user.id}}";
     if(userData != undefined && userData != null && userData != "")
     {
     $(location).attr('href', 'https://yourportal.powerappsportals.com/contact-us/');
     }
    });

     

    If I put above code in Web Page directly, then it is not working. Is there any reason?

  • Verified answer
    ragavanrajan Profile Picture
    7,036 Most Valuable Professional on 21 Dec 2021 at 03:30:17
    Re: Redirect to Specific Page after Login

    Hi @hardikv 

     

    Place the below code in your profile web page (Localised content > Custom JavaScript) or any web page depending on your business need. 

     

    $( document ).ready(function() {
     console.log(555,"Redirect check");
     $(location).attr('href', 'https://yourportal.powerappsportals.com/contact-us/');
    
    });
    
    
    

     

    Done the testing. It is redirecting to contacts page in my case. 


    Hope it helps. 
    ------------

    If you like this post, give it a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.

  • H V Profile Picture
    1,510 on 20 Dec 2021 at 11:32:28
    Re: Redirect to Specific Page after Login

    Hi @ragavanrajan  & @chleverenz 

     

    Thanks for your suggestion.

     

    I have tried to modify Home Web Template and redirect to specific page. However it is not working as expected.

     

    {% if user %}
    <script>
     window.location.href='./contact-us/'
    </script>
    {% else %}
    
    <div class="wrapper-body">
     <section class="page_section section-landing">
     <div class="container">
     <div class="row ">
     <div class="col-md-12">
     <br>
     <br>
     <br>
     <br>
     <h1 class="section-landing-heading">{% editable snippets 'Home/Title' type: 'text' %}</h1><br>
     <h2 class="section-landing-sub-heading">{% editable page 'adx_summary' type: 'html', liquid: true %}</h2>
     <br>
     <br>
     </div>
     </div>
     </div>
     </section>
    
     <section class="page_section">
     <div class="layer_up">&nbsp;</div>
     <div class="container">
     <div class="content-home">
     {% include 'Page Copy' %}
     </div>
     </div>
     <div class="layer_down">&nbsp;</div>
     </section>
    <div class="push"></div>
    </div>
    
    {% endif %}

     

  • ragavanrajan Profile Picture
    7,036 Most Valuable Professional on 19 Dec 2021 at 20:27:35
    Re: Redirect to Specific Page after Login

    Hi @hardikv 

     

    The preferred and standard way is to change the liquid scripting in the Home web template. 

     

    The example below is redirecting to the "contact-us" page. 

     

    {% if user %}
    //if any user logs in
    <script>
     window.location.href='./contact-us/'
    </script>
    {% else %}
    //Home web page code, if you don't want to display the page when the user is being redirected
    {% endif %}
    //Home web page code, if you want to display the page when the user is being redirected

     

    Hope it helps. 
    ------------

    If you like this post, give it a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.

  • Verified answer
    Christian Leverenz Profile Picture
    1,214 on 16 Dec 2021 at 12:45:56
    Re: Redirect to Specific Page after Login

    Hi @hardikv ,

    did you have a look on https://docs.microsoft.com/en-us/powerapps/maker/portals/liquid/liquid-objects#user ?

    In fact if there is the need for a user-specific page you could look, whether you are on the home or profilepage or whatever and in case of logged in user navigate to a page, which is somehow user-dependent.

    You could also look, whether your page referrer was the login. may be, this could help to identify, that you just logged in...

     

    Hope i got the question right, have fun,

      Christian

  • ragavanrajan Profile Picture
    7,036 Most Valuable Professional on 16 Dec 2021 at 04:32:55
    Re: Redirect to Specific Page after Login

    Hi @hardikv 

     

    Have a look at the below thread mate. 

    https://powerusers.microsoft.com/t5/Power-Apps-Portals/Redirect-after-T-amp-C/m-p/912659#M7102 

    Hope it helps. 
    ------------

    If you like this post, give it a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,765 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard
Loading complete