Directing Specific User After Logging In

We have a client that owns a gym. Their customers have an online “member area” which I have created. However, my client wishes for me to send only specific users that basically have not paid their membership fee to a specific page letting them know that their account is temporarily disabled; client does not want to “block” their access or delete their profile. Any suggestions or workarounds that could assist me to achieve this??

First you need to connect the logged in users to some data collection where their paymentStatus is stored. Then after they logged in, query that data collection and check if they paid. If they haven’t redirect them to that page that states they have to pay.


One way is to use a router which will do the work behind the scenes.

Using the beforeRouter() function to see if the user has paid up might look something like this:

export async function Members_beforeRouter(request) {

	let userId =;
	let path = request.path[0];
	path = path.replace(/-/g , " "); // remove dashes in dynamic page path

	// check if user has paid
	let status = await getPaidStatus(userId); // supply a function that checks is use paid
	if (status === "paid") {
		return next(); // user paid, so show the member's page

	// If we get here the user has not paid,
	// so we redirect to the payment page.	
	return redirect(PAYMENT_PAGE_URL);

I hope this helps. It should at least get you started.


1 Like

Yisrael, I’ve added the following router code for a dynamic page, but none of the code ever executes. My dynamic page is setup as “profile/update” with “{ID}” as the dynamic parameter. Can you advise?

import {forbidden, next} from ‘wix-router’;

export function CookProfile_beforeRouter(request) {
//TODO: write your code here…

console.log(“before router called”);

export function CookProfile_afterSitemap(sitemapRequest, sitemapEntries) {
//TODO: write your code here…
console.log(“afterSitemap called”);

export function CookProfile_Router(request) {
//Add your code for this event here:
console.log(“router called”);

export function CookProfile_SiteMap(request) {
//Add your code for this event here:
console.log(“Sitemap called”);