Hi everyone !!!
This question, I searched for every where, but didn’t get any proper answer…
Here’s it is →
I have a database called “Members” which stores ‘userId’ ‘name’ and ‘email’
So, what I am trying to do is when a user enters my home page, if he/she is logged in then they should be redirected to another dynamic page… If not logged-in then nothing happens…
I found the APIs not very understandable…
So, if anyone can provide any examples or clue, it will be very useful !!! (Not Wix.Location.to() )
Thanks J.D
I was just asking if one user enters one page of my site, if he/she is logged-in then they should be redirected to a dynamic page otherwise, nothing !
Biggest example →
When I type wix.com/ if I am logged-in then they redirect me to My Sites page.
If not logged-in then to the Wix page
@jonatandor35 Thanks for letting me know!
After you commented about this I just created a new page…
So, can you help me here → when the user is on this page if she/he is logged in then they should be redirected to a dynamic page otherwise to this page itself…
@ajithkrr You should create a router page:
(where you add a new page, there’s also an option to create a router page and you should select it (it can’t be a name of an already-exist static page).
Then in the routers.js file (on the back end), you should make the redirect:
// backend/routers.js
import {ok, redirect} from 'wix-router';
import wixUsersBackend from 'wix-users-backend';
export function pagename_Router(request) {
const user = wixUsersBackend.currentUser;
const isLoggedIn = user.loggedIn;
if(!isLoggedIn) {return ok("pagename"); }
return redirect('/destination-page-name/' + user.id );
}
I’m not sure if you’re talking about the router page itself or the redirection page.
If it’s the latter, you can go to the page settings > SEO and change it from there.
You should also have a look at: https://www.wix.com/corvid/reference/wix-router/sitemap