Enable edit buttons for comments based on current user.

This is what I got so far:

import wixUsers from 'wix-users';
import wixData from 'wix-data';

$w('#button9').hide();
		    		
$w.onReady(function () {
		    		
	const currentUser = wixUsers.currentUser;
	if (currentUser.loggedIn) {
		currentUser.getEmail().then(email => {
	  wixData.query('Afiliados').eq('email', email).find()
	  .then(() => {
	$w("#repeater1").onItemReady( ($w, itemData) => {
	    	if (itemData.currentUser.loggedIn) {
	    		$w('#button9').show();
	    		
				}
			});
		});
	});
	}
});

This time it is showing all the buttons and not just the current user’s . It seems that the lines below are not doing anything at all but the rest of the code is working:

 $w("#repeater1").onItemReady( ($w, itemData) => 
{ if (itemData.currentUser.loggedIn) {

You are still searching the data collection for email field but you wrote that it is the users id you store?

I’ve been trying all sorts of different things. This is what I got now:

  1. I’m working on dynamic page, the URL contains the user id.
    2.The user’s image, email, ID, etc… are being stored in the ‘Afiliados’ collection.
  2. I set the button to be hidden on load and enabled it by default in the properties panel.
  3. The comments are being stored in my ‘Comunidad’ collection, as a result each comment has its own URL and its own ID (that’s separate from the user id)
  4. When each user makes a comment the user id gets inserted in the title field of my ‘Comunidad’ collection and an ID is also generated for each comment.
import wixUsers from 'wix-users';
import wixData from 'wix-data'; 

$w.onReady(function () {
   let currentUser = wixUsers.currentUser;
    if (currentUser.loggedIn) {
      currentUser.getEmail().then(ID=> {
        wixData.query('Afiliados','_id')
        .eq('_id', ID)
        .find() 
        .then(() => {
        	
			$w("#repeater1").forEachItem( ($w, itemData) => {
        $w('#button9').show()
        (itemData.currentUser.loggedIn);
});
});
	});
   }
   });

I gotta tell you now, I’m quite confused…
This code is only showing me the button that’s on the top comment and not the ones that are on the comments the current user made, which is what I want it to do.


I hope I’m making myself clear. This is all new to me and I don’t understand it fully. But believe me, I’m trying. :frowning:

You write now that you store the users ID in the title field in the data collection? If that is true the query you run will not find anything. Change it.

wixData.query(‘Afiliados’)
.eq(‘title’, ID)

Test that

No luck. It’s still doing the same thing. :frowning:

Someone from the Wix team is needed here please. Anyone?

Guess somethings just stay unanswered on this forum.