Is it possible to hide a section when member is logged in?

Question:
Is it possible to hide a section when member is logged in?

Product:
Velo

What are you trying to achieve:
I want a section to disappear when they have already signed in. If the user it is not signed in, the section should be visible.

What have you already tried:
used this code, but didn’t work:

import wixUsers from 'wix-users';

$w.onReady(function () {
    // Check if the current user is logged in
    wixUsers.onLogin(function (user) {
        if (user.loggedIn) {
            // User is logged in, hide the section
            $w('#create_account_1').hide();
        } else {
            // User is not logged in, show the section
            $w('#create_account_1').show();
        }
    });
});

Additional information:
[Include any other pertinent details or information that might be helpful for people to know when trying to answer your question.]

Is it possible to hide a section when member is logged in?

Yes, this is possible.

import wixUsers from ‘wix-users’;

Wix-Users-API is a depricated one → you shouldn’t use it anymore.
Thisfor you have the new Wix-Members-API.

2024-05-09 11_12_58-Window

First read the API and try to solve your problem by yourself.
Also take a look onto the numerous examples given inside of this forum.

Similar problems you can find in this post…

This one could be useful for you…

Maybe this one too…

…or this one…

…or this OLD BUT GOLD ONE ???