'not show' the plans-pricing page and redirect to other URL

Question:
Currently, my events are for specific plan holders only, hence the page permissions.
I want to ‘not show’ the plans-pricing page because it says “Get a pricing plan to access this page…” instead direct them over to my memberships page.

Product:
Wix Editor

What are you trying to achieve:
This is my code right now:

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

let isRedirecting = false;

$w.onReady(function () {
  // Check if the user is logged in and not already redirecting
  if (!isRedirecting && wixUsers.currentUser.loggedIn) {
    // Check if redirected from plans-pricing
    const isPlansPricing = wixLocation.url.includes("/plans-pricing") && wixLocation.url.includes("appSectionParams");

    if (isPlansPricing) {
      // Set the flag to prevent multiple redirections
      isRedirecting = true;

      // Redirect to memberships URL with no delay
      wixLocation.to('/memberships', {suppressHistory: true});
      return; // Add this line to prevent the rest of the code from executing
    }
  }

  // Continue with your existing logic for active pricing plans, allowed plans, and other actions
  // ...

  // Example: Redirect to the upgrade page for users with specific plans
  // wixPaidPlans.getPricingPlans()
  //   .then((plans) => {
  //     // Your existing logic here
  //   })
  //   .catch((error) => {
  //     console.error("Error fetching pricing plans", error);
  //   });
});

If you go to https://www.findyourtribe.co.nz/nelson-events and tries to RSVP (after signing up or log in), it will direct to /memberships but it still shows the plans-pricing page. Please see video - Screen Recording 2023-12-29 at 6.33.06 AM.mov - Google Drive

What have you already tried:
Checked forum articles
Modify code, add timeout, remove timeout

Additional information:
NA

Code inside $w.onReady will not execute until the page is fully loaded so it may help to move the redirect code outside of the onReady. Though the page will probably still flash by a bit.

Another option would be to make a custom repeater for listing events and then determine where to direct the users when they click the RSVP button rather than on the /plans-pricing.

First move the redirect logic over to the page with the repeater and use onItemReady to define what the repeater should do when it gets new items and one of the RSVP buttons is clicked. The $item().onClick() handlers will be very useful here.

Then populate the repeater’s data property with the data from the Events collection created by the Wix Events app.