Sign in Action Button

great thanks!

Is there a reason why my user profile sheet isn’t coming up as an option? I added Row IDs and entered some data.

I can’t think of any (obvious) reason.
Maybe a screen shot of what your User Profiles sheet looks like in the Data Editor?

1 Like

I found out, I didn’t have an avatar column, is that necessary? I don’t really want users to upload images.

1 Like

I believe all 3 of email, name & avatar are necessary. If you don’t want to use avatar, just don’t add a component for it. :slightly_smiling_face:

but the default “blank face” image will always appear correct?

Yes, I’m not aware of any way to get rid of that.
But you could always replace it with a randomly generated image.

1 Like

Oh or maybe I can create column in google sheets that automatically enters my logo into that image column whenever a new name and email is added?

1 Like

Yeah, actually I just did a quick test and it looks you can’t use a computed column for the avatar. So my previous suggestion won’t work.

But your idea should be fine :+1:

2 Likes

Will try it thank you!

Hi Darren, So I did the above, seems to work, but the user can change the image to something else. Do you know if there is anyway to stop that? How do you deal with the wrong type of images being uploaded?

1 Like

hmm, that’s a good question. If there is a way to do that I am not aware of it. The only thing I can think of would involve a scripting solution with a trigger. ie. if a user changes the image, then immediately overwrite it with the correct image.

Perhaps @Jeff_Hager or @ThinhDinh might know of a way to disable this.

1 Like

No, there isn’t a way. Let 'em change it. They’re the only ones that have to look at it.

Ah ok! so if someone uploads a nude or something, doesn’t it get saved on my glide sheet?

Well, yeah, but if you assign it to a column that’s not used anywhere else in your app, then nobody else will see it.

OK I’ll see how it goes once I figure this favorites thing. I’ll add the logo as a default then they can change it if they want. Thanks!

1 Like

@Jen_NYCP - just for a bit of fun, I coded up something that would automatically change the image back. I’ve tested it, and it works fine, albeit with a short delay.

function enforce_profile_image(event) {
  var profile_sheet_name = 'Users';  // Replace with the name of your user profiles sheet
  var image_col = 4; // Replace this with the column number that contains the image (A=1, B=2, C=3, etc)
  var image_url = 'https://randomuser.me/api/portraits/women/74.jpg'; // Replace this with the URL of your logo
  
  var sheetname = event.source.getActiveSheet().getName();
  if (sheetname != profile_sheet_name) {
    return;
  }
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName(sheetname);
  var data = sheet.getRange(2,image_col, sheet.getLastRow()-1, 1).getValues();
  data.forEach(function (row) {
    row[0] = image_url;
  });
  sheet.getRange(2,image_col, sheet.getLastRow()-1, 1).setValues(data);
} 

You would use that with an On Change trigger. If you’re not sure how to configure triggers, I covered this in a recent tutorial (Part 4). If you wanted to use it, note that you’d need to replace the variable values on the first 3 lines.

2 Likes

Oh, thank you for this!! I think it would be weird to change the image back once a user uploads one. Only if it was possible for them not to have the option at all, Or I’m thinking to have select graphics they can choose from. Not sure if that is possible.

1 Like

You can check out this concept.

2 Likes

Will check it out. Thanks!

1 Like