Code to get _id from URL

Hi, I have a Dynamic page that show the profil of a user. When on that page, I can see the ID of that user in the URL as picture show below.


On click of a button, I need to be able to write in a database let’s call it “Test” the userId of that profil, the active user id that is log-in and another comment field that I have on that same page that is called #commentname.

I know how to grab the actual logged-in user with the code…
let user = wixUsers.currentUser; and let userId = user.id; (This will give me the ID of the current user)

but I don’t know how to grab the ID of the profil I am visiting. So the final objective here is to be able to write in the database “Test” the ID of the Profile I am viewing, the ID of the current user that is log-in and the field #commentname.

Can you help :slight_smile:

thanks

Hey,
wix-location gives you access to the site url. Once you have it, you can just take the part that you need from it.

I hope it helps

import wixUsers from 'wix-users';
export function button_click() {
	wixLocation.to(`/database-name/dynamicpage-name/${wixUsers.currentUser.id}`);