Trying to hide button from everyone expect the page author

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.

Hi,

Note that you are getting the item _id instead of the owner id.
To retrieve the owner id write the following:

const ownerID = $w('#dynamicDataset').getCurrentItem()._owner;

Thank you so much! It works!

I had some other issues but they were due to formatting, not coding.

This was the final code:

import wixDataset from ‘wix-dataset’ ;
import wixUsers from ‘wix-users’ ;

$w.onReady( function () {

$w( "#dynamicDataset" ).onReady(() => { 

const ownerID = $w( ‘#dynamicDataset’ ).getCurrentItem()._owner;

if (wixUsers.currentUser.id === ownerID) {
$w( ‘#EditLocationBt’ ).show();
$w( ‘#EditHistoryBt’ ).show();
$w( ‘#EditProductBt’ ).show();
} else {
$w( ‘#EditLocationBt’ ).hide();
$w( ‘#EditHistoryBt’ ).hide();
$w( ‘#EditProductBt’ ).hide();
}

}); 

});

the final code worked for me once i removed

import wixDataset from ‘wix-dataset’ ;