import wixWindow from 'wix-window'; import wixUsers from 'wix-users'; import wixData from 'wix-data'; export function logInButton_click(event) { wixWindow.openLightbox('login') } export function registerButton_click(event) { wixWindow.openLightbox('Sign up') } export function profilePic_click(event) { wixWindow.openLightbox('Sign up') } export function continueWithoutAccountButton_click(event) { $w("#welcomeScreen").hide(); } $w.onReady(() => { if (wixUsers.currentUser.loggedIn) { if (wixUsers.currentUser.loggedIn) { $w("#welcomeScreen").hide(); } else { $w("#welcomeScreen").show(); } } if (wixUsers.currentUser.loggedIn) { let user = wixUsers.currentUser; wixData.query("Members") .eq("_id", user.id) .limit(1) .find() .then((results) => { $w("#shareSomething").placeholder = "What's new " + results.items[0].username; $w.onReady(() => { waitForLoading(); }); function waitForLoading() { setTimeout(() => { $w('#loadingScreen').hide('FadeOut'); }, 2000); } } ,$w.onReady(function () { let user = wixUsers.currentUser; wixData.query("Members") .eq("_id", user.id) .limit(1) .find() .then((results) => { $w("#loginCheck").text = "Hello " + results.items[0].username; function loginCheck() { if (wixUsers.currentUser.loggedIn) { $w("#star").hide(); let user = wixUsers.currentUser; wixData.query("Members") .eq("_id", user.id) .limit(1) .find() .then((results) => { $w("#loginCheck").text = "Hello " + results.items[0].username; }); } else { $w("#loginCheck").text = "Please log in."; $w("#star").show(); } } //there is an error here.
top of page
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
bottom of page
Your code is a complete catastrophical CHAOS!
1) No STRUCTURE!
2) CHAOTIC!
3) WRONG!
If you one day want to become a good programmer, than start to pay attention on following code-rules!
1) Try always to code in a systematical way.
2) Try to keep your code as short as possible (including short and plausible named elemen-IDs).
3) NEVER use more than just --> 1 <-- onReady() in your CODE!
4) Use CODE-TAGS/CODE-BLOCKS to show your code --> better readebilaty!
5) Format your code the right way --> better readability!
6) CODE --> STEP by STEP!
So let's do it one more time --> STEP by STEP with a good OVERVIEW, READABILITY and logical programming.
1) If you do not have any imports, your very first line of code will ALWAYS be --> $w.onReady() !!!!!!
import wixWindow from 'wix-window'; import wixUsers from 'wix-users'; import wixData from 'wix-data'; $w.onReady(() => { ........... your whole code here inside the BRAKETS...... });
So let's start to construct your code....
As i can see, you will need USER-DATA in your code, so let's first get all needed User-Data first. To be able to work with the collected user-data later in our code...
We alredy have our starting code-snipet and now we add just one further code-line, to get everything about our current-user. And of course we do also a console-log to inspect the OUTPUT!
import wixWindow from 'wix-window'; import wixUsers from 'wix-users'; import wixData from 'wix-data'; $w.onReady(() => { // get USER-DATA.... let USER = wixUsers.currentUser; console.log(USER); });
Oh look! Wix has improved their User-API ! Did you knew that?
There is something new!!! --> -getSlug()
It is even so NEW --> that it even isn't included in the CODE-COMPLETION!
So before we continue, perhaps we should first inspect everything about our current user? Let's do it first!
import wixWindow from 'wix-window'; import wixUsers from 'wix-users'; import wixData from 'wix-data'; $w.onReady(async() => { // get USER-DATA.... let USER = wixUsers.currentUser; console.log(USER); let userEmail = await USER.getEmail(); console.log("EMAIL: ", userEmail); let userSlug = await USER.getSlug(); console.log("SLUG: ", userSlug); let userRoles = await USER.getRoles(); console.log("ROLES: ", userRoles); let userPPlans = await USER.getPricingPlans(); console.log("P-Plans: ", userPPlans); let userStatus = USER.loggedIn; console.log("Status: ", userStatus); let userRole = USER.role; console.log("Role: ", userRole); });
Ok! Now we have everything we need to know about our current logged in user right?
Normaly it looks like this in a good structured format....
And our OUTPUT until now is the following .....oooouuuuuu wow, take a look at this...
We have now all the User-Data we need!
Ohhh NO NO NO NO NO!
I surely will not do all the work for you!
Now it's your turn!
RECONSTRUCT all your CODE one more time! The best what you can do --> delete your old one and give it a new try!
We will see us again in few hours, days, weeks --> as much time as you need, to present a new cleaned up code, with an eye-burning structure 😉.
And of course next time you will use --> CODE-BLOCKS!