Page linked in menu based on PrivateMembersData ID?

Hi!
I’ve created a dynamic item page with the privateMemberData, to easily use the data of the user (to say “welcome back, name” for example), without having to perform data queries. On the page I show some files which I pull from another database.

My problem is that when I add this page to the menu I have to choose a specific ID to use for the item page (which results into a 404 when this specific user is not logged in)… I would like this to be dynamic and based on the ID of the logged in user, and of course show the login screen when the user isn’t logged in yet… Is this in any way possible?

Thanks!

That is because the Wix Members app collection of Members/PrivateMembersData collection is only able to be viewed by the specific member, if any other member tries to view it then they will not have the correct permissions and be having the error.
https://support.wix.com/en/article/corvid-wix-members-privatemembersdata-collection-fields

Dynamic Item Page links.
https://support.wix.com/en/article/linking-to-a-dynamic-page#linking-to-a-dynamic-item-page-to-display-a-selected-item

So as you have stated, that you can’t use a dynamic link on the menu as you will need to link that dynamic link to a specific members page through the Wix Editor settings, which obviously won’t work if it belongs to a member who is not signed in.

Have a look at this tutorial here for making a Members Profile page which lets you link a member to their own profile page.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

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

You won’t be able to make the menu in the Wix Editor dynamic to suit and only show items when the user is logged in or not.

To do that you would have to create your own site menu which only shows certain menu links when the user is logged in etc and then have the Profile menu link set as the wixLocation.to link in the code example above, obviously changing the prefix to whatever you have called your page.

Your best bet is to have something like a Members page on your site menu which is only open to site members after they have logged in, so that they need to login to be able to view any content.

I have used the member profile tutorial above to setup a similar page where anybody can view the Members page, however if you are not logged in as a site member it will only show a branded logo and the login button.

The site member will need to click on the login button to call up a custom lightbox so that the site member csan log themselves in, then after the member is logged in successfully the lightbox closes and the page is automatically refreshed which makes the code run again and the hidden member only elements are then shown.

On any member clicking on the logout button (note that this button changes from login to logout when the member is logged in) the site member is logged out and the page is refreshed again and the member only elements are hidden again.