Hi, everybody
Good Day !
I am a bit confused in the code of my Wix website.
In my site, I have a dataset , a repeater - in the repeater a text, image and a button. But I want the button to show only if a particular user is logged in.
For Example - Ajith is logged in to my website. I want to make him see the button on a paricualar container of a repeater.
For more info -
![](https://static.wixstatic.com/media/a27d24_54858e4d3731410ebadd9a69578b0d0b~mv2.jpg/v1/fill/w_147,h_71,al_c,q_80,usm_0.66_1.00_0.01,blur_2,enc_auto/a27d24_54858e4d3731410ebadd9a69578b0d0b~mv2.jpg)
Here is an input in my website, When the user types anything, I want to get which member uploaded it.
![](https://static.wixstatic.com/media/a27d24_c155e20264b842d4a6bdcf42d85ccf5e~mv2.jpg/v1/fill/w_147,h_71,al_c,q_80,usm_0.66_1.00_0.01,blur_2,enc_auto/a27d24_c155e20264b842d4a6bdcf42d85ccf5e~mv2.jpg)
Then in the repeater, I want to show the 'Delete Post' button only to the user who uploaded it.
Hope you understand,
Ajith
Thank You Russian-Dima,
Is there any feature, that would change the size of repeater, if there is no button to one user ?
Once More Thanks,
Ajith
Ok, i think now i understand what you want to know.
Well, your mission will be ...
1) Find out how to get your button in the repeater.
https://www.wix.com/corvid/reference/$w/repeater/foreachitem
$w.onReady(function () { 2 $w("#myDataset").onReady( () => { 3 $w("#myRepeater").forEachItem( ($item, itemData, index) => { 4 if(itemData.button){ 5 $item("#myText").text = "Yes Ma'am!"; 6 } 7 else { 8 $item("#myText").text = "No way!"; 9 } 10 } ); 11 } ); 12} );
2) Find out the current user-id of logged in user.
import wixUsers from 'wix-users'; let user = wixUsers.currentUser; let userId = user.id; console.log(userId)
3) Then make a little if-querry to check if the user has the permission or not in your database.
This video here could also be very interesting for you.
https://www.youtube.com/watch?v=E8W3nTazcNo&t=1127s
Hello Ajit,
to show if a user is logged in, you can do it like this...
import wixUsers from 'wix-users'; $w.onReady(function () { let user = wixUsers.currentUser; let isLoggedIn = user.loggedIn; if(!isLoggedIn){console.log("User not logged-in.");} else {console.log("User logged-in");} })
To achieve your aim, you have to do the following steps...
1) Create a DATABASE or an ARRAY which will contain all the permissions of each user.
2) Get the current loged-in user's ID or e-mail to identify who is currently logged in and look into your DATABASE for PERMISSIONS for this user.
Take also a look at this example here....
https://russian-dima.wixsite.com/meinewebsite/comments