Redirect if not a "paid plan" member?

Hello,
New member here - lurker for some time, appreciate all the help!

I have a paid plan membership site and have created a Members only page which paying members can access only.
How can I make a redirect page so when a non paying member clicks this PAID MEMBERS page, they are redirected to the membership options?
I cant seem to find any info on this.

Thanks in advance

Hi Aspect,

You can do this by getting the plans for the current user with wix-users in code. Then use wix-llocation to redirect them. Here is a code example

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
let user = wixUsers.currentUser
let categories = new Array()

$w.onReady(function () {

user.getPricingPlans()
.then((pricingPlans) => {
    pricingPlans.forEach(function(item){
    categories.push(item.name)
    })
    if (categories[0] === undefined){
        console.log("user is not a paying member")
        wixLocation.to("/site1");
        }
    else {
        console.log("user is a paying member")
        wixLocation.to("/site2");
        }
    return
    })
});

The Stripe Payment Processing example demonstrates how to do this using Routers .

Great stuff, Yisrael! I’ve just had a look and those routers seem like an elegant solution to this.

Does it work for You?

hello - î m using your code. i am not an programmer. i changed only those 2 things. /site1 and /site2 - anything else i need to adapt…??