# Component visibility based on signed in user

**URL:** <https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792>\
**Category:** Ask for Help\
**Created:** [May 14, 2021, 1:01pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792 "2021-05-14T13:01:22Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roger](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Roger](https://community.glideapps.com/u/Roger)\
**Post date:** [May 14, 2021, 1:01pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/1 "2021-05-14T13:01:22Z")

</div>

Hi,

I want to selectively show components on the screen based on, if the signed-in user is an existing user or a new user. Just so that you are aware, in my implementation I have a Users sheet that captures email of the user. Therefore, if the user is a new user the email will not be listed there.

I am having a hard time implementing selective visibility of components. Any assistance is appreciated.

Thank you.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 14, 2021, 1:11pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/2 "2021-05-14T13:11:43Z")

</div>

If they are signed-in users, and you have enabled user profiles, you should have the email already. Do you have a public app?

---

<div class="post-metadata">

**Author:** ![Roger](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Roger](https://community.glideapps.com/u/Roger)\
**Post date:** [May 14, 2021, 1:17pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/3 "2021-05-14T13:17:13Z")

</div>

Yes, the link to the app is

> **[imagesheet](https://hypnotic-earth-1770.glideapp.io/)**

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 14, 2021, 1:29pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/4 "2021-05-14T13:29:22Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/f/cf64c15181d0c8cafe982c57cc77a36b5b07e344.png)

I see you’re requiring users to sign in here, what I meant to ask what if you don’t require users to sign in to see the app’s content, so it’s not the case here.

In that case, have you enabled user profiles?

> **[User Profiles](https://docs.glideapps.com/all/reference/security-and-per-user-data/user-profiles)**

---

<div class="post-metadata">

**Author:** ![Roger](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Roger](https://community.glideapps.com/u/Roger)\
**Post date:** [May 14, 2021, 1:56pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/5 "2021-05-14T13:56:20Z")

</div>

I went through this, but couldn’t figure out where to look for to check if user profiles are enabled.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [May 14, 2021, 2:05pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/6 "2021-05-14T14:05:12Z")

</div>

Make sure you are in the Layout view…

![Screen Shot 2021-05-14 at 10.02.15 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/5/551c223b7803cd0bc994a1f398715c459ab4489a.png)

- then click on the hamburger menu (top left in the phone display)
- then click on the area at the top where your email address is
- then you should see this on the right…

 ![Screen Shot 2021-05-14 at 10.02.35 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/e/0ef2a1e26abc8a9d80e9f887572f712d4a77caa8.png)

---

<div class="post-metadata">

**Author:** ![Roger](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Roger](https://community.glideapps.com/u/Roger)\
**Post date:** [May 14, 2021, 2:11pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/7 "2021-05-14T14:11:06Z")

</div>

Thank you. Yes, I navigated to the screen in your image above and found that “Sheet” was not pointing to my Users sheet. Does this mean I did not have User profiles enabled?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [May 14, 2021, 2:13pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/8 "2021-05-14T14:13:12Z")

</div>

Sounds like it, yes.

It needs to be pointing at a sheet that has at least the following three columns:

- Email (must be an Email column)
- Name (must be a Text column)
- Image (must be an Image column)

The column names are not important, but the column types are.

---

<div class="post-metadata">

**Author:** ![Roger](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Roger](https://community.glideapps.com/u/Roger)\
**Post date:** [May 14, 2021, 2:14pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/9 "2021-05-14T14:14:16Z")

</div>

OK. Great! Let me give that a try and revert.

---

<div class="post-metadata">

**Author:** ![Roger](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Roger](https://community.glideapps.com/u/Roger)\
**Post date:** [May 14, 2021, 2:25pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/10 "2021-05-14T14:25:21Z")

</div>

@Darren_Murphy That was easy, thank you. But realized that due to the privacy settings the email id’s are anonymized. My implementation requires the actual email ID for a subsequent interaction. Any idea how do I achieve it without upgrading my account?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [May 14, 2021, 2:34pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/11 "2021-05-14T14:34:23Z")

</div>

Without going pro, the next best method would be to explicitly ask your users to provide their “real” email addresses, and store them in a separate column in your Users sheet.

You could do it as part of an onboarding process, so it doesn’t appear too odd to your users.

---

<div class="post-metadata">

**Author:** ![Roger](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Roger](https://community.glideapps.com/u/Roger)\
**Post date:** [May 14, 2021, 2:36pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/12 "2021-05-14T14:36:39Z")

</div>

Yes, was thinking on similar lines. Thank you for the help @Darren_Murphy !

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 14, 2021, 11:44pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/13 "2021-05-14T23:44:01Z")

</div>

I was having a thought about using a script to replace all the anonymous emails by the real email once the user inputs it.

Let’s say the flow is like this, assuming you already had the anonymous email.

- Ask for the user’s real email writing to a user-specific column, then set it to the Sheet column using a button (to avoid triggering the script when the user has not finished the input when you let them write directly to the column).

- Once the button is clicked, use the script to find the anonymous email associated with the real email that has just been put in, then find that anonymous email across all Sheets and replace it with the real email.

Is this possible?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [May 15, 2021, 4:42am UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/14 "2021-05-15T04:42:23Z")

</div>

I had a [similar idea](https://community.glideapps.com/t/allowing-users-to-change-their-email-address/19007) some months ago (for different reasons), but I ended up not going through with it as I decided it wasn’t really a good idea…

I still have the code that I wrote to do this, you’d be welcome to a copy if you’d like to experiment with it?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 15, 2021, 5:01am UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/15 "2021-05-15T05:01:45Z")

</div>

Yeah would love to. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [May 15, 2021, 5:16am UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/16 "2021-05-15T05:16:03Z")

</div>

Here you go. Offered “as is”, with no warranty 😛  
Just looking through it, I’d probably do it quite differently now.  
That’s always the way, you look at code you wrote in the past and think “what on earth was I smoking back then!?” 🤣 🤪

```auto
function check_user_email_updates() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var user_map = build_user_map();
  var sheet = ss.getSheetByName('User Email Updates');
  var row = 3;
  while (row <= sheet.getLastRow()) {
    var data = sheet.getRange(row, 1, 1, 6).getValues();
    var status = data[0][5];
    if (status == 'Pending') {
      var old_email = data[0][1];
      var new_email = data[0][2].trim();
      var username = user_map[old_email];
      console.log(['Updating email address for ', username, old_email, new_email]);
      search_and_replace(data[0], data[1]);
      var d = new Date();
      sheet.getRange(row, 1).setValue(username);
      sheet.getRange(row, 5).setValue(d);
      sheet.getRange(row, 6).setValue('Completed');
    }
    row++;
  }
  sheet.getRange(2, 4, sheet.getLastRow(), 2).setNumberFormat('yyyy-mm-dd hh:mm:ss').setHorizontalAlignment('left');
  format_sheet('User Email Updates');
}

function search_and_replace(from, to, sheets) {
  sheets = [
    'Authorised Emails',
    'Payments',
    'App:Responses',
    'Realtime Pool',
    'Pool',
    'Private Leaderboards',
    'Users',
    'Response Archive',
    'User Picks',
    'Player View Choices',
    'App: Logins',
    'App: Comments'
  ];
  sheets.forEach(function (sheet) {
    process_sheet(sheet, from, to);
  });
}

function process_sheet(sheet, from, to) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheet);
  var values = sheet.getDataRange().getValues();
  replace_in_sheet(values, from, to);
  sheet.getDataRange().setValues(values);
}

function replace_in_sheet(values, from, to) {
  for (var row in values) {
    var replaced_values = values[row].map(function (original_value) {
      return original_value.toString().replace(from, to);
    });
    values[row] = replaced_values;
  }
}

```

---

<div class="post-metadata">

**Author:** ![Roger](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Roger](https://community.glideapps.com/u/Roger)\
**Post date:** [May 16, 2021, 11:25am UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/17 "2021-05-16T11:25:58Z")

</div>

If I am making the user enter his email, I might as well make him edit the row in the user profile that corresponds to him. Isn’t this possible?

In fact I did not see the recent responses on this thread and initiated a new one [here](https://community.glideapps.com/t/edit-form-to-update-details-of-signed-in-user-in-user-profile/26849).

---

<div class="post-metadata">

**Author:** ![NoCodeAndy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nocodeandy/32/62530_2.png) [@NoCodeAndy](https://community.glideapps.com/u/NoCodeAndy)\
**Post date:** [January 17, 2024, 4:52pm UTC](https://community.glideapps.com/t/component-visibility-based-on-signed-in-user/26792/18 "2024-01-17T16:52:08Z")

</div>


