Hi.
I made 2 different sites and experienced the same issue.
I followed the code in this article
I was able to customize the buttons and even add a customized profile picture image that switches from icon to member’s profile (if uploaded)
The problem is when a member logs in the do not see the “Login” button switch to “Logout” and the “Profile” button to go from hidden mode to display. I discovered that the login in process actually goes through but the page doesn’t load correctly and it’s stuck showing the same state. Only if I refresh the page upon login in I am able to see the buttons correctly - and everything works perfectly.
Has anyone experienced this? Couldn’t get help from wix coders so I hope someone has an answer.
P.S - A work around this issue would be having a script that automatically refreshes the page once upon logging in. As much as it’s a band-aid it will help me get through the project.
Thanks for reading this and appreciate all inputs.
As it seems you don’t have a ‘members’ collection created in your site
you can either create one using the editor or follow this article to get a login bar, account page and more by simply installing members area: Site Members: Adding and Setting Up a Members Area | Help Center | Wix.com
Let me know if the issue is resolved, Tom
Hi Tom.
I am not sure which site you are referring to but your suggestion still doesn’t make much sense to me. I am most definitely aware of “members collection”. This feature is simply too limited for what I am working on.
Wix’s members collection user profile section doesn’t allow adding custom input fields.
The tutorial on this article has nothing to do with Wix’s default member’s area: https://support.wix.com/en/article/how-to-build-your-own-members-area-using-code#login-page I created a database and a custom log buttons just like the tutorial explains. Everything works except the login page doesn’t download correctly upon logging in. I have to refresh the page to see the logged-in state of the buttons (“Login” as “Log out” / “My Profile” change from hidden to show). Once I refresh everything works fine. This also means I do not need Wix’s members area and it’s limiting features.
3. Either this code (copied below from the wix tutorial-except I added a third button #image) is missing something or the backend is not communicating with the code.
4. As an alternative solution/ If anything, a simple one-time refresh upon logging in code could fix the issue but I haven’t been able to find the code that works with wix.
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
$w.onReady( () => {
if (wixUsers.currentUser.loggedIn) {
$w(“#login”).label = “Logout”;
$w(“#profileButton”).show();
$w(“#image”).show();
} else {
$w(“#login”).label = “Login”;
$w(“#profileButton”).hide();
$w(“#image”).show();
}
} );
export function loginButton_click(event,$w) {
// user is logged in
if (wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w(“#login”).label = “Login”;
$w(“#profileButton”).hide();
$w(“#image”).show();
} );
}
// user is logged out else {
let userId;
let userEmail;
// prompt the user to log in
wixUsers.promptLogin( {“mode”: “login”} )
.then( (user) => {
userId = user.id; return user.getEmail();
} )
.then( (email) => {
// check if there is an item for the user in the collection
userEmail = email; return wixData.query(“Members”)
.eq(“_id”, userId)
.find();
} )
.then( (results) => {
// if an item for the user is not found
if (results.items.length === 0) {
// create an item
const toInsert = {
“_id”: userId,
“email”: userEmail
};
// add the item to the collection
wixData.insert(“Members”, toInsert)
. catch ( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w(“#login”).label = “Logout”;
$w(“#profileButton”).show();
$w(“#image”).show();
} )
. catch ( (err) => {
console.log(err);
} );
}
}
Hi Yakup,
The logged-in state is not consistent with your database collection.
Upon login you are trying to access a collection named “Members” which doesn’t exist in both of your websites.
You can resolve this issue by renaming the collections “Member-Profile” and “Member-Database” to “Members”.
Another way would be changing the code:
wixData.query(“Members”) to wixData.query(“Member-Profile”)
and
wixData.query(“Members”) to wixData.query(“Member-Database”)
Hi Tom.
So, I went and wiped out and started everything from scratch. I am now able to see the buttons going to the correct state. (Login turns to Logout and My Profile button shows up with the name and it’s linked to the My Profile Page where the user can update their profiles)
The issue now is that the My Profile page and or the buttons don’t show the current logged in user info. The image, the member name buttons and the My Profile form show the previously logged in member’s info. I set the dataset with a filter Owner=>Is=>Logged-in but that still didn’t fix the issue.
Hey thanks for the feedback. I went back and wiped clean as well. Now I got one of the websites to work perfectly. www.wssmda.com Let me know if I can help.
The one weird issue I am dealing with is connecting a simple button to a dynamic page. Creating a new copy with a new url to see if this works and something is broken with the old one.
Yup, same here been stuck on projects trying to fix them and not getting paid on time. I didn’t realize there were issues with buttons today. Just checked the link and added myself to “I am having this issue”. Not much we can do other than waiting to see if it gets fixed. Sucks having to explain the client that it’s not your fault.
Tom
I noticed you requested to be a member for https://toyohariwebsite.wixsite.com/website-2 (I just approved so you have access)
I was able to fix the login issue.
I am pretty much done with member profile update (through “My Profile” button) and "Practitioner page that lists all members.
The practitioners page takes a while to load. Any suggestions?
Would you be able to point me to a code that makes the user info fields/boxes responsive so the space is adjusted based on the characters. As you see the name and last name or the City and State always have dead spaces.
Thank you.
Hi Tom.
Can you please advice on what I can do to make the “Practitioners” page download faster?
Also, for the life of me I can not figure out a tutorial that specifically addresses adding a search bar that brings results from the database in a custom REPEATER MENU that has text input fields connected to the database.
Hey Yakup,
Regarding the performance issue, I would considering making two changes:
Remove unused datasets (currently you have duplicate members datasets)
Use pagination bars to reduce data load time, here’s an article you can get started with: CMS: Adding and Setting Up a Pagination Bar | Help Center | Wix.com
Secondly, one way of removing those dead spaces using code is to collapse inputs with empty values whenever repeater loads its items, like so:
$w.onReady(() => {
$w('#repeater2').onItemReady(($item, itemData) => {
if (!itemData.practiceName) $item('#text58').collapse();
// Repeat for every input...
})
})
@tombe Can you elaborate what you mean by, “one way of removing those dead spaces using code is to collapse inputs with empty values whenever repeater loads its items, like so”
Ok, had hoped pagination was something additional. Be nice for a repeateor item to have “layers”, where each item would have pages so can decrease load times
@dragosdanetiu collapsing an input (or any element) will set its dimensions to zero, meaning other elements will take the free space.
For further information please refer to the docs: