Hi there guys.
Would it be possible to put a button on a page, but make it visible only for myself ?
Basically a button that I can only use, not visible for other users.
Thank you in advance
First- get your userId by putting the following code in the priview mode →
(any page)
import wixUsers from 'wix-users';
$w.onReady(function () {
let user = wixUsers.currentUser;
let userId = user.id;
console.log(userId);
});;
Copy the userId…
On the page where the button is →
#button1 - button
import wixUsers from 'wix-users';
$w.onReady(function () {
let userid = "435245"; //paste your userId instead of the numbers
if(userid === wixUsers.currentUser.id) {
$w('#button1').show();
} else {
$w('#button1').hide();
}
});
it gives me an error here :
} else {
See I have updated the code !!!
Sorry …
$w.onReady(function () {
let userid = "435245"; //paste your userId instead of the numbers
if(userid === wixUsers.currentUser.id) {
$w('#button1').show();
} else {
$w('#button1').hide();
}
});
@ajithkrr Yep, that works, you’re a star ! thank you so much
@londonsk8boarding Your welcome !!!
@ajithkrr And that will work only with my log in because the id right ?
@londonsk8boarding You can either login or be logged out …userId(s) will be there. But the two userId(s) will be different …
@ajithkrr What I mean is, only I will see that button, regardless people are logged in or logged off, because that’s my ID there
Or, if they log in, they will see the button too ?