# Show Element, When A Particular User Is Logged In

**URL:** <https://forum.wixstudio.com/t/show-element-when-a-particular-user-is-logged-in/26055>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [July 26, 2020, 6:00am UTC](https://forum.wixstudio.com/t/show-element-when-a-particular-user-is-logged-in/26055 "2020-07-26T06:00:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajithkrr](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ajithkrr/32/20520_2.png) [@ajithkrr](https://forum.wixstudio.com/u/ajithkrr)\
**Post date:** [July 26, 2020, 6:00am UTC](https://forum.wixstudio.com/t/show-element-when-a-particular-user-is-logged-in/26055/1 "2020-07-26T06:00:28Z")

</div>

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://us1.discourse-cdn.com/wix/original/3X/8/0/802b19a1893a568ea1446284d7220ffa8abc58bb.jpeg)  
Here is an input in my website, When the user types anything, I want to get which _ **member** _ uploaded it.

 ![](https://us1.discourse-cdn.com/wix/original/3X/0/3/0372342e405313df1ddfcaca9fb8aaeb90275991.jpeg)

Then in the repeater, I want to show the ‘Delete Post’ button only to the user who uploaded it.

Hope you understand,  
Ajith

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [July 26, 2020, 8:50am UTC](https://forum.wixstudio.com/t/show-element-when-a-particular-user-is-logged-in/26055/2 "2020-07-26T08:50:23Z")

</div>

Hello Ajit,

to show if a user is logged in, you can do it like this…

```javascript
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](https://russian-dima.wixsite.com/meinewebsite/comments)

---

<div class="post-metadata">

**Author:** ![ajithkrr](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ajithkrr/32/20520_2.png) [@ajithkrr](https://forum.wixstudio.com/u/ajithkrr)\
**Post date:** [July 27, 2020, 4:13am UTC](https://forum.wixstudio.com/t/show-element-when-a-particular-user-is-logged-in/26055/3 "2020-07-27T04:13:32Z")

</div>

Hai Russian-dima,  
Thank You for your help,

What I am trying to do is to show to button (in the repeater) to only those who upload the data in database.  
For others , the button should not be there

Ajith

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [July 27, 2020, 5:41am UTC](https://forum.wixstudio.com/t/show-element-when-a-particular-user-is-logged-in/26055/4 "2020-07-27T05:41:49Z")

</div>

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](https://www.wix.com/corvid/reference/$w/repeater/foreachitem)

```javascript
$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} );

```

1. Find out the current user-id of logged in user.

```javascript
import wixUsers from 'wix-users';

let user = wixUsers.currentUser;
let userId = user.id;
console.log(userId)

```

1. 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://us1.discourse-cdn.com/wix/original/3X/f/e/feff6b31b9141025c0400ee18dff8e4916aedf68.jpeg "Modify repeater items using Wix Code") ](https://www.youtube.com/watch?v=E8W3nTazcNo&t=1127s)

---

<div class="post-metadata">

**Author:** ![ajithkrr](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ajithkrr/32/20520_2.png) [@ajithkrr](https://forum.wixstudio.com/u/ajithkrr)\
**Post date:** [July 27, 2020, 12:13pm UTC](https://forum.wixstudio.com/t/show-element-when-a-particular-user-is-logged-in/26055/5 "2020-07-27T12:13:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [July 27, 2020, 12:23pm UTC](https://forum.wixstudio.com/t/show-element-when-a-particular-user-is-logged-in/26055/6 "2020-07-27T12:23:48Z")

</div>

You can try to collapse the elements which are not needed (untested).

---

<div class="post-metadata">

**Author:** ![ajithkrr](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ajithkrr/32/20520_2.png) [@ajithkrr](https://forum.wixstudio.com/u/ajithkrr)\
**Post date:** [July 27, 2020, 2:35pm UTC](https://forum.wixstudio.com/t/show-element-when-a-particular-user-is-logged-in/26055/7 "2020-07-27T14:35:54Z")

</div>

Ok, I will make the ‘untested’ into ‘tested’  
Thanks,  
Ajith
