top of page
Crumpled Fabric

2

Reload Your Wix Site After User Logs In

Click URL to copy

Apr 27, 2023

2 min read

WIX Ideas Team

Tags: Velo by Wix Reload Wix Website Wix Location Wix Members

Reload Wix Page Onlogin() by Wix Ideas

Hello everyone, welcome to Wix Ideas. In this tutorial you will learn how to reload or refresh your wix site after the user logs in.


If you're using Wix to build your website, you're probably familiar with the Wix Members app. It allows you to create a members area on your website, where users can log in, access exclusive content, and interact with each other. But once a user logs in, how do you make sure that they see the most up-to-date version of your site? Or a piece of code you want to run immediately they log in?


The solution is simple: just reload the page using the WixLocation API. Here's how you can do it:


First, import the authentication and WixLocation modules at the top of your code:



Then, inside the onLogin event handler, add the following line:



This will tell Wix to reload the current page as soon as the user logs in. The wixLocation.url property refers to the current URL, so you don't need to worry about passing any additional parameters.


And that's it! Now, every time a user logs in, the page will automatically reload, ensuring that they see the most up-to-date version of your site.


As an additional bonus, you can also update the label of the login button to show "My Profile" once the user is logged in, using the authentication.loggedIn() method. Here's an example:



With this code, the label of the #profileButton element will change to "My Profile" when the user is logged in, and revert back to "Login" when they log out.


In conclusion, reloading your Wix site after a user logs in is a simple but important step in ensuring a seamless user experience. By using the WixLocation API and the authentication module, you can accomplish this task with just a few lines of code.


Code



Leave a comment (0)

Thanks for leaving a comment🎉

RELATED TUTORIALS 🚀

Exit-Intent Popup on Wix Studio

Exit-Intent Popup on Wix Studio

Trigger a popup when site visitors are trying to exit your website before performing an action

bottom of page