Redirect a user to a default page on sign-in
You can configure a Power Pages site to redirect a user to a default page after the user signs in.
To achieve this, you replace the default studio template that's used as the page layout for the home page. You replace this default template with a custom template that includes JavaScript code to redirect the user to the page of your choosing. The steps are:
- Make a copy of the default studio template web template.
- Add JavaScript code to the web template copy.
- Create a corresponding page template.
- Modify the home page to use the modified template.
Make a copy of the default studio template
Open the Portal Management app, go to Web Templates, and open the Default studio template.
Copy all of the content that follows the
<!-- Default studio template. Please do not modify -->
line.Select New to create a new web template record.
Give the template a name (for example, Home page template), and select the Website where you want to implement the redirect functionality. Paste the content from the default studio template, and then select Save.
Add JavaScript code
In the new template, add the following JavaScript code. Replace
./page/
with the partial URL of the page you want to direct the user to:{% if user %} //if any user logs in <script> window.location.href='./page/' </script> {% else %} //Home webpage code, if you don't want to display the page when the user is being redirected {% endif %} //Home webpage code, if you want to display the page when the user is being redirected
Select Save.
Create a page template
In the Portal Management app, select Page templates.
Select New, and then create a new page template record.
Give the page template a name (for example, Home page template). Select the Website record where you want to have the functionality, choose the Type as Web Template, and select the Web Template you created in the previous step.
Update the home page
Go to the Portal Management app.
In Web Pages, locate the Home webpage record. Change the Page Template to the page template record you created earlier. Select Save & Close.
Now, when a user signs in, they'll be redirected to the page you specified in the JavaScript code in the updated web template.