# Button Visibility based on Table of Admin Users

**URL:** <https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932>\
**Category:** Get Help\
**Created:** [April 15, 2022, 2:37am UTC](https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932 "2022-04-15T02:37:53Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris170](https://avatars.discourse-cdn.com/v4/letter/c/48db29/32.png) [@chris170](https://forum.adalo.com/u/chris170)\
**Post date:** [April 15, 2022, 2:37am UTC](https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932/1 "2022-04-15T02:37:53Z")

</div>

I have a table of Teams. Each Team can have many Users who are Admins of that Team. I have a table called TeamAdmins with fields for User and Team.

I have a button for “Edit Post”. A Post belongs to a Team.

I only want the “Edit Post” button to appear if the current logged in user is in the TeamAdmin table.

However, this is never an option in the visibility filters.

Any thoughts on how to achieve this? Thanks!

 ![1-adalo](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/6/7/67764daa57dbec004de92b9dc7e410658cde868f.jpeg)

---

<div class="post-metadata">

**Author:** ![MikesClub](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/mikesclub/32/12754_2.png) [@MikesClub](https://forum.adalo.com/u/MikesClub)\
**Post date:** [April 15, 2022, 3:33am UTC](https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932/2 "2022-04-15T03:33:11Z")

</div>

Instead of using a separate table for TeamAdmins, I would just add a true/false property to your Users collection. Call it “Admin” and set the field to true for any users who are also Admins. Then make the button visible if User \> Admin is true.

---

<div class="post-metadata">

**Author:** ![chris170](https://avatars.discourse-cdn.com/v4/letter/c/48db29/32.png) [@chris170](https://forum.adalo.com/u/chris170)\
**Post date:** [April 15, 2022, 3:45am UTC](https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932/3 "2022-04-15T03:45:47Z")

</div>

A user can be an admin of multiple teams and teams can have multiple admins.

So, I don’t think that will work.

> ![](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/mikesclub/45/12754_2.png "MikesClub") | [MikesClub](https://forum.adalo.com/u/mikesclub)  
> April 15 |
> 
> - | - |

Instead of using a separate table for TeamAdmins, I would just add a true/false property to your Users collection. Call it “Admin” and set the field to true for any users who are also Admins. Then make the button visible if User \> Admin is true.

---

<div class="post-metadata">

**Author:** ![Dilon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/dilon/32/39815_2.png) [@Dilon](https://forum.adalo.com/u/Dilon)\
**Post date:** [April 15, 2022, 5:38am UTC](https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932/5 "2022-04-15T05:38:04Z")

</div>

Hi Chris,

Welcome to the community 🥳

Try this :

All TeamAdmins\>Count\>is equal to\>1. And add a filter that User’s\> ( I guess this is a One to Many to relationship between User and TeamAdmins ) email\>is equal to\>Logged in user’s\> email.

Or you can create a Many to Many relationship between Users and Teams and add Current Post\>Team’s\>Users ( Many to Many relationship )\>All\>Contains\>Logged in user.I have read some posts that when the users count increases in that relationship this will become slow. And they suggest to use Joint Tables like this. Not sure.

Thank you

---

<div class="post-metadata">

**Author:** ![chris170](https://avatars.discourse-cdn.com/v4/letter/c/48db29/32.png) [@chris170](https://forum.adalo.com/u/chris170)\
**Post date:** [April 15, 2022, 12:30pm UTC](https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932/6 "2022-04-15T12:30:27Z")

</div>

Thank you, but I don’t seem to be able to get that to work.

To start with, shouldn’t I need something that says Current Logged In User is or is not linked to Team Admins for the Current Team?

Maybe I’m thinking too much like a SQL database.

---

<div class="post-metadata">

**Author:** ![Dilon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/dilon/32/39815_2.png) [@Dilon](https://forum.adalo.com/u/Dilon)\
**Post date:** [April 15, 2022, 12:50pm UTC](https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932/7 "2022-04-15T12:50:29Z")

</div>

> [@chris170](#):
>
> Thank you, but I don’t seem to be able to get that to work.

The 2 ways? As for my knowledge the 1st way should work and the 2nd the way has to work for sure.

> [@chris170](#):
>
> To start with, shouldn’t I need something that says Current Logged In User is or is not linked to Team Admins for the Current Team?

This logic is there when you use Many to Many relationships but Logged in user is in down in the filter as like Current Team\>Admins\>Contains\>Logged in user or Current Team\>Admins\>Does not contains\>Logged in user

---

<div class="post-metadata">

**Author:** ![chris170](https://avatars.discourse-cdn.com/v4/letter/c/48db29/32.png) [@chris170](https://forum.adalo.com/u/chris170)\
**Post date:** [April 15, 2022, 1:08pm UTC](https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932/8 "2022-04-15T13:08:41Z")

</div>

For the first way, I have one to many relationship between User and TeamAdmin. Here is what I see on the screen. I don’t understand how you enter:

All TeamAdmins\>Count\>is equal to\>1. And add a filter that User’s\> ( I guess this is a One to Many to relationship between User and TeamAdmins ) email\>is equal to\>Logged in user’s\> email.

into the Visibility filter.

 ![1-adalo2](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/f/9/f9213e6088c95ade9c0130192a9d7c8af7e07cbc.jpeg)

---

<div class="post-metadata">

**Author:** ![Dilon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/dilon/32/39815_2.png) [@Dilon](https://forum.adalo.com/u/Dilon)\
**Post date:** [April 15, 2022, 1:14pm UTC](https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932/9 "2022-04-15T13:14:06Z")

</div>

Add this filter :

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/3/f/3fdc297e92cca9532daec74fa872cac71ff32929.png)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/1/3/1350238ef830ae46c9fd072db70ceb2798c45f9d.png)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/6/1/61070321ff3c2165e804631da3e752f7b894c128.png)

---

<div class="post-metadata">

**Author:** ![chris170](https://avatars.discourse-cdn.com/v4/letter/c/48db29/32.png) [@chris170](https://forum.adalo.com/u/chris170)\
**Post date:** [April 15, 2022, 2:10pm UTC](https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932/10 "2022-04-15T14:10:53Z")

</div>

It is still showing the button for all users who are TeamAdmin of any Team. I need the button to only display for TeamAdmin of that particular Team.

If logged in as a User who is not TeamAdmin of any Team, then button does not display.

Thank you so much for all your help!!!

---

<div class="post-metadata">

**Author:** ![Dilon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/dilon/32/39815_2.png) [@Dilon](https://forum.adalo.com/u/Dilon)\
**Post date:** [April 15, 2022, 2:27pm UTC](https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932/11 "2022-04-15T14:27:16Z")

</div>

Ah I guess I understand what you want to do! You have a post and that post belongs to a Team and if that Team’s admins view that show the button and if not don’t show. Correct?

Then you need to add the filter like this ( same but select current post\>team’s\>admins\>count ) :

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/f/d/fdcf3bd2e5132d6a0d85a5c4a0d1522d7e4fa34e.png)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/1/d/1dd3bfc39ee596d104f0441b8d016f86666f9a5f.png)

[![](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/1/3/1350238ef830ae46c9fd072db70ceb2798c45f9d.png) ](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/1/3/1350238ef830ae46c9fd072db70ceb2798c45f9d.png)

[![](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/6/1/61070321ff3c2165e804631da3e752f7b894c128.png) ](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/3X/6/1/61070321ff3c2165e804631da3e752f7b894c128.png)

> [@chris170](#):
>
> Thank you so much for all your help!!!

Your Welcome!

---

<div class="post-metadata">

**Author:** ![chris170](https://avatars.discourse-cdn.com/v4/letter/c/48db29/32.png) [@chris170](https://forum.adalo.com/u/chris170)\
**Post date:** [April 15, 2022, 3:19pm UTC](https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932/12 "2022-04-15T15:19:10Z")

</div>

That works!!! Thank you!

I guess I don’t fully understand the logic behind why the filter on Count = 1 ???

If viewed in a web browser, would a non-TeamAdmin be able to go to a specific URL and edit or add posts as if they were a TeamAdmin? Just wondering how “secure” these visibility settings are???

---

<div class="post-metadata">

**Author:** ![Dilon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/dilon/32/39815_2.png) [@Dilon](https://forum.adalo.com/u/Dilon)\
**Post date:** [April 15, 2022, 4:52pm UTC](https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932/13 "2022-04-15T16:52:55Z")

</div>

> [@chris170](#):
>
> That works!!! Thank you!

Awesome and Your Welcome!

> [@chris170](#):
>
> I guess I don’t fully understand the logic behind why the filter on Count = 1 ???

It’s like if the Logged in user is in the Admins table. Like if there is a record that is the Logged in user then the count becomes 1 and button displays. But if Logged in user is not on that Table then button is not visible.

> [@chris170](#):
>
> would a non-TeamAdmin be able to go to a specific URL and edit or add posts as if they were a TeamAdmin?

I believe they are secure! If that user is not a admin then that user should not see the button.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/system/32/40401_2.png) [@system](https://forum.adalo.com/u/system)\
**Post date:** [April 25, 2022, 4:53pm UTC](https://forum.adalo.com/t/button-visibility-based-on-table-of-admin-users/25932/14 "2022-04-25T16:53:22Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
