Saving custom columns to the User table with custom Sign Up form

Hello,

So I’ve been able to integrate the User Service into my app to understand how the service and Users table work.

I’ve extended the Users table to include some custom columns like Name, Organization, etc…

I’m proceeding to create a custom Registration form asking for all these custom fields and then creating a new user using the API.

What’s the best way to save all the custom fields into the Users table?
I only see the signup_with_email() method available on the Users object.

Thanks
SS

If I understand correctly, you are trying to extend the functionality of the standard Users service (i.e., you want to create your own sign-up/login flow)

There is a tutorial (and clone-able project) on customizing user authentication and it may help:

https://anvil.works/docs/how-to/custom-user-auth

There are also several posts on this forum under “custom login flow”. Feel free to ask more questions if needed. I know a lot of folks here have had experience with this topic.

2 Likes

@alcampopiano So after watching the video and going through the clone sample app provided in the video, it appears that if I go custom login flow, I essentially have to implement all User Service functions myself?

Also, it appears that the way to then get data into the User table is through a straight table manipulation in the codebase.

I guess I was hoping to see a way to leverage the existing functions on the User Service by either overriding or overloading. https://anvil.works/docs/api/anvil.users

The other thought I had was to use the User Service to do a signup_by_email() only using the Email and Password properties and then do a straight update on the User table for all my custom properties. This will prevent me from having to write a whole bunch of code like hashing, reset password, etc…

Do you think the second approach can work?

SS

Yep, I tend to agree that a fully custom flow may be overkill for you. I think that using the standard approach, and just building onto it simply as you’ve suggested is perfectly fine. I mean, hey, why not ask the user for additional information after involking the standard user flow. That seems reasonable to me. You would simply then have to have a way of dealing with that data (or lack of it) in terms of validation and how those new fields interact with the users table/user registration.

Best of luck with your development!

2 Likes

Users are database rows. Once Anvil creates them, you can fill in any custom column values using Anvil’s regular database features.

2 Likes