add dynamic page link to a button

hello everyone
I want to add dynamic page link to a button… I did like this but it is still not working …
when I click the button it must check the collection and get the user email , then add it in the link… however the button is not working

the code is like this :

import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;

export function button1_click(event, $w) {


.then( (results) => {
let firstItem = results.items[0];;

} )
. catch ( (err) => {
let errorMsg = err;
} );


Hi Warda,

Few things you should be aware of:
First, Be sure that the link path for the dynamic page is correct.
Second, i think you are missing the most important part in your query, which is the current user that you want his Email, because in your code seems to return always the first item from the database, Right?

So what you should do is to add a query that finds the current user then get his email then you can added to the link :slight_smile:

For more information, check this Wix Api - HERE

Hope this helps!


hello @mhammouz
thanks for your help,

I changed the code , I think it’s better to get the current user’s email instead of checking the database so I make it like this but it is still not working , can you please tell me where is the problem?

export function button1_click() {
//Add your code for this event here:

let user = wixUsers.currentUser;
.then( (email) => {
let userEmail = email;;
} );

I get this error that the page is not here and in the url instead of the current user’s email I just get (userEmail) word

I solved the problem :
instead of writing the UserEmail in the string (/student/info/userEmail);

it must be like this:- (`/student/info/’ + userEmail);



It is not – (`/student/info/’ + userEmail);

It is – (/student/info/ + userEmail);

Eagle-eye-Ajit! :grin:
But what you did not see is the DATE of this post ^^

I don’t think taht the post-opener still wants to know the aswer/solution.:grin:

@russian-dima :sweat_smile::sweat_smile:

i am new at wix i want to create a custom button which will lead users to another website blog section in sidebar but i don , t know how to do so should i hire someone to do so becasue it require HTML