PLS HELP dynamic pg only shows most recent entry when live

Hi y’all … I’m stuck (again)! And I could really use some input ASAP, I need to get this off to the clients. I know I saw some post(s) about this a week or 2 ago, but now can’t seem to find an answer

I have a dynamic Member Profile page which displays the current user’s info from the database on the left (this is previously entered using a form) and then on the right, displays the dated they joined, and if they’re an active member (noted in DB by boolean) then a membership expiration date is calculated and shown, otherwise, some text appears notifying the user their membership is expired, and for each instance (active/expired) the button shown changes.

Preview expired member:

Preview active member (contact info removed for privacy):

I’ve worked out all of the other code (I think), and it’s fine in preview mode but only the MOST RECENT entry from the database shows up. In other words, in preview, I can see each individual member’s profile with their info and the correct dates & button, however, when I go to the live site, I only see the profile of the last person to register (not me!). I need to make sure the currently logged in user sees their profile page and only their profile page when they click on a button “my account”

I’ve synced the database, changed all the permissions to “anyone” …

So I think it’s in the code (below) and the issue lies with using getCurrentItem and/or my onReady – that it’s actually getting the most recent item, not the item associated with the current user.

Page Code (dynamic page, url: www…com/members/ID and database

data.js Backend Code (called for date calculation of 1-year membership expiration)

Also, you can see some of how I got to my code here, if it helps: https://www.wix.com/code/home/forum/questions-answers/working-with-dates-and-time-in-wix-code

Note: I used a variation on the “standard” member profile code to gather my member info, db and login page…

Please, please help! My brain’s turning into spaghetti I think

And THANK YOU in advance to anyone who’s got advice…!?

Hi Annie,
Could you please add a link to your site, or copy the URL from your editor so I could check it?

Hi Omer! Sorry for not responding earlier, I appreciate the help…

Here’s the URL for the site from the editor https://editor.wix.com/html/editor/web/renderer/edit/11bb3fca-2ce8-4c94-aa4e-99b18ff18d4c?metaSiteId=627a2768-28a6-4492-a4fe-ee25ebb563bf&editorSessionId=3F0BB17C-036C-46CA-816D-0B315D023E7C&referralInfo=my-account

The live URL is grounddelivery.org/members/ID

When I checked to see the fields in the Members collection, I noticed that while “Owner” field appears in the sandbox, in the Live schema there is no such field. this means that in the published site the membersDataset you defined cannot use this field to filter the relevant items (as you defined in the membersDataset configurations).

To fix this you should add the Owner field to your Live data collection items. You can do that by adding a new record item with this field, or sync one item from the sandbox - then the dataset filter should work for new items properly as long as you update the Owner field with each new item you save.

Let me know if that fixed the issue.

Also, I noticed you defined the Members collection permission to read, write and update items by “anyone”. This means that anyone can read and edit any item, even ones that any other user created. I would suggest to make sure this is what you need. If any user should only see and edit his own records, change the permissions accordingly. In this case, you will not need to filter items by Owner in the dataset, as it will be predefined by the collection permissions.

1 Like

Hi Omer

So I read through this and played around a bit but it’s still not working/I’m a little confused…

  1. I see the field Owner (_owner) and unhid it (it’s blank for every member, btw) and understand that that’s a an automatic field that’s part of the database: CMS (Formerly Content Manager): About Your Collection Fields | Help Center | Wix.com – so I unhid it – but I feel like I don’t need to add that filter to the dataset, that the code should do the work, but was trying to make anything I could work… so I removed that filter, because the database permissions and the code should work

So here’s the problem now:

I have button(s) whose code is the following (see accountButton and Member Portal and Forum page, for instance):
export function accountButton_click() {
wixLocation.to(/Members/${wixUsers.currentUser.id});
}

In my live version, those buttons seem to be taking me here each time: grounddelivery (404 Error) and that user ID isn’t associated with any member in my database…

Not sure why that’s happening? (for reference, my user ID on this site, when types in directly, does go to my own profile page grounddelivery)

Any insight? :slight_smile:

Thanks!!

Hi Omer, just wondering if you have any other ideas of how to get this working? I really need to get theis site off to my clients ASAP… thanks again!

Hi Annie!

I’ve looked through the pages you mentioned in which the buttons don’t seem to function properly.
I might have missed some of them but I didn’t see any button that is linked to the function you wrote.

Make sure that the event in the buttons properties (View properties => event) has the same name as the function you wrote.

Hope it helps!
Best of luck!

Doron. :slight_smile:

P.S.
Did you manage to solve the issue from the original post?
Is the info presented in the page belongs to the current user?

Hey Doron – thanks so much for your input! And for catching my mistake!

Last night, I changed the properties of that “My Account” button, but forgot to update the onClick event in the properties manager, the code, as you see was updated. I just made the change, as you pointed out, but unfortunately, that doesn’t resolve my issue…

My problem still just seems to be that I can’t get the current user’s member profile (from dynamic page) to appear for that user, and that user only, when they click a button with the following link, or using my code above – and both times, the main function used if the getCurrentUser (or current user ID)

export function accountButton_click() {
wixLocation.to(/Members/${wixUsers.currentUser.id});
}

Right now, there are buttons that SHOULD link to each member’s profile from 2 pages, and those both use that code for their button …
The Member Portal https://editor.wix.com/html/editor/web/renderer/edit/11bb3fca-2ce8-4c94-aa4e-99b18ff18d4c?metaSiteId=627a2768-28a6-4492-a4fe-ee25ebb563bf&editorSessionId=3F0BB17C-036C-46CA-816D-0B315D023E7C&referralInfo=my-account
and the Forum https://editor.wix.com/html/editor/web/renderer/edit/11bb3fca-2ce8-4c94-aa4e-99b18ff18d4c?metaSiteId=627a2768-28a6-4492-a4fe-ee25ebb563bf&editorSessionId=3F0BB17C-036C-46CA-816D-0B315D023E7C&referralInfo=my-account

And still, my code (above) on the Members (ID) dynamic page is also fetching the wrong info, because while the functions seem to work, I’m not seeing the proper user.

Does that make sense? Any thoughts?

Thanks so much :slight_smile:

So, I’m testing everything I can think of, and something else strange seems to be happening…

My user ID as a registered member of the site is 92f412b6-34ce-4df1-b0fc-6029f7de3e4a
and if I type this into the URL, it works and I see my profile… but when I navigate there using my menu & buttons, I always end up at a 404 Error page now with a userID in the URL that doesn’t match any in the database

So I think the issue is definitely with the code on the Members profile page, because on that page I have a button that links to the Members update (ID) dynamic page, and that one works correctly and takes me from my profile to my profile’s update page – so something with getting the current user’s info in my code – which is necessary to calculating my expiration date and reformatting the dates – seems to be my issue … I think

Hi again Annie!

After inspecting your site I’ve discovered what seems to be your problem.

At the Member Portal - The button that redirects the user to his dynamic page is connected by two methods, Link to a dataset and Event of the button (the function you wrote).
Those two can’t co-exist and so the solution is to simply remove the event from the button (the trash bin in the properties of the button).

At the Forum page - It seems that the “My Account” button isn’t connected at all!
You’ve got a loose dataset hanging in there which is not connected to anything, the button has no events nor links so all you have left to do is to connect them to each other! :slight_smile:

I’ve managed to reproduce the error you were describing and then to get to my own dynamic page with the correct info so I’m pretty sure that should solve your problem but if you keep facing this issue or any other, we’ll be glad to provide assistance.

Hope it helps!
Best of luck!

Doron. :slight_smile:

Hi Doron – thanks again! Again, more silly mistakes because I’ve been working on this all for so long.
Fixing the buttons did resolve the issue of returning a 404 Error

But I’m still only being directed to the most recent entry in the database. When I click the buttons from the Portal or the Forum now (both connected thru the dataset), I am directed to the profile page for John Doe (grounddelivery), not my own page for Annie Lucid (grounddelivery)

So the buttons do seem fixed (small victories!), but my page is still pulling from the top database entry, I think because of my page code on the dynamic Members (ID) page and the getCurrentItem function

Related Page Code:

And in data.js …

Does that make sense? I think that’s the only place left that can be causing my issue, because otherwise the page functions and calculates the dates per my code correctly.

Any ideas on how to get this worked out?
Thanks again :slight_smile:

Any suggestions Doron? or Omer?

Hi all, I’m STILL stuck on this – any suggestions on how to fix? PLEASE?