Reload Page on Login

Hi,

I’ve added this code to the page (please see below) - when a user logs in, the page is supposed to reload itself, however, when testing it using Wix’s Test Site. It does not reload when I log in. Can you please check my code & see what I did wrong? Many thanks in advance.

import wixLocation from ‘wix-location’ ;

wixUsers . onLogin (( user ) => {
let userId = user . id ; // “r5cme-6fem-485j-djre-4844c49”
let isLoggedIn = user . loggedIn ; // true
let userRole = user . role ;
if ( wixUsers . currentUser . loggedIn ) {
wixLocation . to ( “/certificates-badges” );
}
});

import wixUsers from ‘wix-users’ ;
//import wixWindow from ‘wix-window’;

$w . onReady ( function () {

let user = wixUsers . currentUser ;
let userId = user . id ;
let isLoggedIn = user . loggedIn ;

user . getPricingPlans ()
. then ( ( pricingPlans ) => {
let firstPlan = pricingPlans [ 0 ];
let planName = firstPlan . name ;

if ( planName === “Associate” ) {
$w ( “#MemberStop” ). show ();
$w ( “#MemberGo” ). hide ();

}
else {
$w ( “#MemberStop” ). hide ();
$w ( “#MemberGo” ). show ();

}}
)})

  1. All the import s must be at the top of the page code

  2. The wixLocation url needs to be the full page url (including the domain). You can do:

wixLocation.to(wixLocation.url)

Thank you so much, J.D.!