Logged in homepage / Logged out homepage

I am trying to create a members site, where you come to the homepage for the first time and can request to join/signup. Then when you signup, you get shown a different homepage (still on the main .com domain). How do I do this?

You can create 2 different contents for the same page:
If the user is logged in collapse the visitor contents and expand the member contents and vise versa.
What’s the best way to do it depends on the specific contents.

Alternative, you can use a MultyState Box, with 2 states: Members and Visitors and select the State accordingly.

Thanks for you reply. Although not sure I know what you mean?

I would like to display 2x completely different pages depending on whether a visitor is logged in or not. So a landing page style page for logged out, and then a newsfeed style page for logged in.

You have 2 options: either to redirect the user from the home to a different URL based on the loggedIn status. Or to stay on the same page but display different contents in it based on whether or not the user is logged in.

@jonatandor35 Ok cool. So how do I redirect to a different URL based on logged in status?

@james50138 I guess you can user routers:
https://support.wix.com/en/article/corvid-about-routers
https://support.wix.com/en/article/corvid-creating-a-router
https://www.wix.com/corvid/reference/wix-router.html

And for the case that the user landed on the home page and then logged in, you can use wixLocation: https://www.wix.com/corvid/reference/wix-location.html#to
inside user.onLogin() :
https://www.wix.com/corvid/reference/wix-users.html#onLogin

But I’ve never used any router here, so I won’t be able to help you if you have a specific question. Other people here can.
:slight_smile:

@jonatandor35 Thanks, I’ve checked those links, but to be honest, I just don’t know what I’m doing. I’m not a coder, so I don’t understand any of that.

I’m just looking for a simple option to display a landing page if the user isn’t logged in…

Can you explain how the collapsing content works for members and visitors?

And the other direction

import wixLocation from 'wix-location';
import wixUsers from 'wix-users';

$w.onReady(() => {
if (wixUsers.currentUser.loggedIn) {
wixLocation.to('/home');
}
wixUsers.onLogin(user => {
wixlocation.to('/home');
})
});

But It will be slower, because the user will have to be redirected. And you will have to use a pre-loader or something so the user won’t see the other contents.

@james50138 There’re different ways to do it depends on what elements you’re going to use.
Are you going to have a strip? a slideshow? a video? Anchors?

Anyway, use multi-state box it’s even easier but is limited in some ways. Not everything can be done.
See an example here;
https://jonatandor35.wixsite.com/mysite-16

With collapse/expand you can do more things, but it’s (a little bit) less convenient to develo).

@deleteduser Thank you for your reply. The redirect when logged in works great, however when you’re not logged in, it keeps opening the login/signup light-box without clicking on anything? I want users to click on ‘Request to join’ button to then bring up the lightbox, on this page: www.bikeslice.com/newhomepage

@jonatandor35 Thanks, appreciate it. But I can’t get your code to work?

@james50138 I put there a button to get the code.
Any way, I’ll put it here too:
Elements: Multy State Box
States: “Preloader”, “Visitors”, “Members”
On the preloader put a “loading” message (and a gif file. optional)
Populate your states.
Use the code:

import wixUsers from 'wix-users';
let user = wixUsers.currentUser;
$w.onReady(() => {
    user.loggedIn ? $w("#states").changeState("Members") :      $w("#states").changeState("Visitors");
    wixUsers.onLogin(() => {
    $w("#states").changeState("Members");
    })
})
//From now on it's for my sign up/log in buttons. You probably don't need that:
export function button2_click(event) {
wixUsers.promptLogin({"mode": "login"});
}
export function button3_click(event) {
wixUsers.promptLogin({"mode": "signup"});
}

P.S. it won’t work with strips as you can’t put them in a state, and if you want to use strips you’ll have to use collapse/expand functions.

Ah. Now I saw your real page and you’re using a full width strips so the multi-state box won’t fit to your needs.

@jonatandor35 Thank you really appreciate your help. This is really useful to know.

Any ideas why the ‘wixLocation.to’ code you put above isn’t working? As that would be the perfect solution :slight_smile:

@james50138 Post your code please.

@J. D. 

import wixLocation from 'wix-location';
import wixUsers from 'wix-users';
$w.onReady(() => {

if (wixUsers.currentUser.loggedin) {
wixLocation.to('/forum');
}

});

@james50138 Your code is fine (if you want to send already logged-in users to “/form”.
but you’re still missing some code for users that weren’t logged in when they entered the page and then then they logged in (see in blue):

import wixLocation from 'wix-location';
import wixUsers from 'wix-users';
$w.onReady(() => {
if (wixUsers.currentUser.loggedIn) {
wixLocation.to('/forum');
}
wixUsers.onLogin(user => {
wixLocation.to('/forum');
})
});