I create a series of dynamic pages that will let a member create an info page about themselves, with an editable page linked to the various info sections by buttons. I want to hide those edit buttons from other users so that the only member who can see these buttons is the page author.
I tried using the code below but it keeps giving me “parsing error: unexpected token {” messages after “user.id === ownerID)” Any suggestions?
import wixData from ‘wix-data’ ;
import wixUsers from ‘wix-users’ ;
$w.onReady( function () {
$w( ‘#EditLocationBt’ ).hide();
$w( ‘#EditHistoryBt’ ).hide();
$w( ‘#EditProductBt’ ).hide();
});
$w( “#dynamicDataset” ).onReady(() => {
const ownerID = $w( ‘#dynamicDataset’ ).getCurrentItem()._id;
If(wixUsers.currentUser.id === ownerID) {
$w( '#EditLocationBt' ).show();
$w( '#EditHistoryBt' ).show();
$w( '#EditProductBt' ).show();
}
}
PS I also used this setup:
import wixData from ‘wix-data’ ;
import wixUsers from ‘wix-users’ ;
$w.onReady( function () {
$w( "#dynamicDataset" ).onReady(() => {
const ownerID = $w( ‘#dynamicDataset’ ).getCurrentItem()._id;
If(wixUsers.currentUser.id === ownerID) {
$w( '#EditLocationBt' ).show();
$w( '#EditHistoryBt' ).show();
$w( '#EditProductBt' ).show();
} **else** {
$w( '#EditLocationBt' ).hide();
$w( '#EditHistoryBt' ).hide();
$w( '#EditProductBt' ).hide();
}
});
});
Which gives me the same error message.