Hello. I have been wrecking my brain for hours. Is there a way that a member can be redirected to the members pages after they login? For some reason, after a user logs in, it stays on the page where the member signup is....
Any help is appreciated. Thank you!
Hello,
To do this, there is a special wix api function called onLogin(). It is called when the user logs in, and you can add code here to redirect to another page using wixLocation.to().
Check out these two functions and let me know if this helps
Best,
Majd
Hi. Please help!
I'm trying to redirect the member to another page when logging in. However, I don't know how to do it.
Here is what I did:
Inside Wix Code I created a file called aModule.jsw in the Backend Section and included the code:
import wixUsers from 'wix-users'; 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; // "Member" wixLocation.to("/get-started"); } );
But no success.
Then, Inside Wix Code I created a file called new-file.js in the Public Section and included the same code.
Again, no success.
Please, how can I do it?
Regards,
Fernando Damasio
I think you should move this code to the "Site" code panel, equivalent to site.js file in the local editor.
Hi @Fernando Farah Maia Damasio
Did you ever get this working? I'd like to do something similar.
Thanks!
Matt