A little background, first. The portion of the website I’m working on has a feature where site members (price plan only) can make a post to a shared content collection page. I want to give the site member the option of deleting their post. I have that button set up, and it even refreshes the page after being clicked and the post is deleted. However, I only want the delete button to show up on the site member author’s post, and no other member’s post. Below is what it currently looks like:
These are two separate posts from two separate members. I’d like to not “give” the site member an option to delete another site members post, even if it doesn’t actually delete their post. Actually, when a signed in site member tries to “delete” another site members post, it’ll just delete the current signed in members post. Currently, my coding to the delete button is:
import wixLocation from 'wix-location';
$w.onReady(function () {
$w("#deleteBtn").onClick( (event) => {
wixLocation.to(wixLocation.url); // refresh current page
});})
I know it has something to do with hiding the delete button on page load, then assigning the “currentUser” role, but I can’t figure out for the life of me how to do this. Any help would be appreciated!
This is what I currently have:
$w("#deleteBtn").hide();
const currentUser = wixUsers.currentUser;
if (currentUser.loggedIn) {
currentUser.getEmail().then(email => {
wixData.query('ideas').eq('businessIndividualName', email).find()
.then(() => {
$w("#listRepeater").onItemReady( ($w, itemData) => {
if (itemData.currentUser.loggedIn) {
$w("#deleteBtn").show();
}
});
});
});
}
$w("#deleteBtn").onClick( (event) => {
wixLocation.to(wixLocation.url); // refresh current page
});})
This is also seeming, to work, but can’t get either one to fully work
$w.onReady(function () {
let user = wixUsers.currentUser;
let userID = user.ID; // "r5cme-6fem-485j-djre-4844c49"
// show delete button to user who submitted comment only
$w("#Repeater1").onItemReady( ($w, itemData, index) => {
console.log(itemData.user); // show data from field "user" which is the id in dev console
if(itemData.user === userID) { //this is checking the user field and comparing it to userId from above
$w("deleteBtn").show();
} else {
$w("#deleteBtn").hide();
}
});
$w("#deleteBtn").onClick( (event) => {
wixLocation.to(wixLocation.url); // refresh current page
});})
Hi James 
First of all, you need to set this button to be hidden on load , and show it only for the owner of the comment.
$w("#Repeater1").onItemReady( ($item, itemData) => {
if (itemData._owner === user.id) {
$item("deleteBtn").show();
}
})
Please note, it’s a good practice to use the $item selector in repeaters instead of the global $w selector in order to be able to specify which scoop you want perform actions on (repeated item or all items)
Hope this helps~!
Ahmad
Ahmad, I appreciate your response! Unfortunately it’s still not working. I’ve set the delete button to hide on load and below is my current coding:
$w.onReady(function () {
let user = wixUsers.currentUser;
let userID = user.ID;
// show delete button to user who submitted comment only
$w("#Repeater1").onItemReady( ($item, itemData) => {
if (itemData._owner === user.id) {
$item("deleteBtn").show();
} else {
$w("#deleteBtn").hide();
}
});
$w("#deleteBtn").onClick( (event) => {
wixLocation.to(wixLocation.url); // refresh current page
});})
It’s because you’re hiding the image with the global selector $w instead of $item , that mean it’ll hide all the buttons in the repeater.
Change the selection scoop to $item and it’ll work, beside, you don’t need to hide the button because it’s already hidden, just use my code exactly as it is and it’ll work.
You can also change the selection scoop of the line that hides the button, but it’s useless since every button is hidden in the first place.
I just copied and pasted your exact coding into my page code:
// show delete button to user who posted only
$w("#Repeater1").onItemReady( ($item, itemData) => {
if (itemData._owner === user.id) {
$item("deleteBtn").show();
}
})
The delete button is still being hidden. Thoughts?
What’s the field that holds the user data in your collection?
I believe this is what you’re in reference to for your question:

Yes, but if users are not who generate these entries in the database the _owner field won’t work, you need to include a reference field in your collection to the members collection and compare its ID instead of the _owner
The process is as follows:
Site member logs on and generates these entries in the database via a submit button with user inputs:
The submit button sends the information into a collection database called “ideas” and the repeater on the collections page shows the idea as the snippet at the top of this post shows. It should be worth mentioning that I am getting this error:
I think there’s a syntax error in your code, to help debug your code you can send me a message on my profile.
I’m not quite sure how to send you a message! When I got to your profile I do not get an option.
Here is the current coding. I’m having trouble defining my $item:
import wixLocation from 'wix-location';
import wixUsers from 'wix-users';
import wixData from 'wix-data';
$w.onReady(function () {
let user = wixUsers.currentUser;
let userId = user.Id;
let $item = $w.("#deleteBtn");
let itemData = ("#Repeater1")
// show delete button to user who posted only
$w("#Repeater1").forEachItem($item, itemData)
if ((itemData._owner === user.Id).hidden) {
$item("#deleteBtn").show();
} else {
$item("#deleteBtn").hide();
}
});
$w("#deleteBtn").onClick((event) => {
wixLocation.to(wixLocation.url); // refresh current page
});
There are three links on my page (Facebook & Whatsapp)
Where’s the error that you get? I see that everything looks okay except the hide() function which I did already told you that it’s useless.
I deleted the else portion with the hide() you just mentioned. The error that I get right now is “parsing error” unexpected token (. This falls on the “let $item = $w.(”#deleteBtn");" line. My $item is not defined properly I guess.
import wixLocation from 'wix-location';
import wixUsers from 'wix-users';
import wixData from 'wix-data';
$w.onReady(function () {
let user = wixUsers.currentUser;
let userId = user.Id;
let $item = $w.("#deleteBtn");
let itemData = ("#Repeater1")
// show delete button to user who posted only
$w("#Repeater1").forEachItem($item, itemData)
if ((itemData._owner === user.Id).hidden) {
$item("#deleteBtn").show();
});
$w("#deleteBtn").onClick((event) => {
wixLocation.to(wixLocation.url); // refresh current page
});
Hey James 
The $item selector can only be used inside repeaters or inside an event function, in repeaters, the $item selector is defined as a parameter, while in event handlers you must get the context from the event.
Repeaters:
$w("#Repeater1").onItemReady( ($item, itemData) => {
// Bind repeater items here
})
Outside the repeater - inside event handlers
$w("#button1").onClick((event) => {
let $item = $w.at(event.context);
})
You can read more about the scoops and how to use the proper selector at the link below:
Hope this helps~!
Ahmad
So what should the coding be as a whole? That’s where I’m struggling
Here you go …
import wixLocation from 'wix-location';
import wixUsers from 'wix-users';
import wixData from 'wix-data';
$w.onReady(function () {
let user = wixUsers.currentUser;
let userId = user.Id;
// show delete button to user who posted only
$w("#Repeater1").onItemReady( ($item, itemData) => {
if (itemData._owner === user.Id) {
$item("#deleteBtn").show();
$item("#deleteBtn").onClick((event) => {
wixLocation.to(wixLocation.url);
})
}
})
});