Logout problem using WIX Members element

Hi guys,
On my website I’m using Wix Members element and I have a dynamic page for members.
When the member click on logout (in Login Bar from Wix) on the it’s dynamic page, he gets error 403 ( Looks like you don’t have permission to view this page. ) and this is the correct behaviour, but what I want is when he click on logout, redirect to home page and of course logout the member.
I don’t know how to catch logout event using Wix Member element, only if I customize login member page.

Can you help me please?

Regards

In your page code on the Dynamic Page add the below

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
// Check if logged in

let user = wixUsers.currentUser;
let isLoggedIn = user.loggedIn; // true / false
if (!isLoggedIn) {
  wixLocation.to("/");
}

Hi Andreas,

Thanks for your reply, but the problem persists.

Hi,
Are you using code? if you do please share the code and the editor’s URL.