How do I save user customData on Signup

I have just been working with Realm but I have hit a dead end when trying to save user data like names and phone numbers when they sign up

so the idea is when a username signs up their full name and phone number gets saved on user data and they will receive an email for the confirmation as usual

Please help with a solution or idea on how I can go about achieving this using Realm

@Jeremie_D_Negie : Have thought of setting up a Realm function which get triggered as soon as sign up is complete.

In that function you can save all the custom information you want in the User Model.

Hi @Mohit_Sharma , thank you for your answer.

Yes, I have set up a function already but what I do not know what to do is pass data to that function.

for example, my function looks like this

exports = async function (authEvent, firstname, lastname, phoneNumber) {
  const user = authEvent.user;
  const collection = context.services
    .get("mongodb-atlas")
    .db("educators")
    .collection("user");

  const updateDoc = { firstname, lastname, phoneNumber, userID: user.id };

  const result = await collection.insertOne(updateDoc);

};

The trigger will call this function on user sign up but how do I pass the required arguments so firstname, lastname, and phoneNumber

Can someone please help with this, I have bee sitting with this problem for a week now

@Jeremie_D_Negie : Once you get the sign-up success callback on the client you can call this function to save the custom information.

@Jeremie_D_Negie did u solve the problem ? if so tell me how please

@Mohit_Sharma i am using a trigger function so how can i pass the arguments from the activity on android studio to that function ?

I wasn’t able to solve the problem ey… I ended up rebuilding the authentication with Nodejs and Postgresql so I can have more control however I was building a project with NextAuth and what I did was show a user a form on the first login to set up their profile. I guess you could set up a way to check whether a user has, for example, a username or something similar if they do you take them to whatever page you otherwise you show them a profile form where they need to fill in their information… Please let me know if you do it otherway

in the same signup activity i logged in and get the user id upload data then i logged out and moved to the login activity

Okay, but MongoDB realm sends a verify email, why not get all those data when after the user verify their email>

@Bouraoui_Ben_abdalla : You can consider checking out this repo, where I can calling a simple SUM function to add two numbers, similarly you call function and pass arguments to it.

@Jeremie_D_Negie : Did you got a chance to validate the approach I suggested you earlier ?

I did, and first I was using Realm with Nextjs, and with the Realm client in javascript you need to be authenticated to call a function so the problem I had was a new user need to verify their account first before performing an action with Realm like calling a function. so that did not work well

G’Day @Jeremie_D_Negie, @Bouraoui_Ben_abdalla :wave:,

I acknowledge it has been a while since you asked these questions. I hope you have been able to find answers to it.

For anyone else, who has the same questions.

This is user-meta data. This depends on the auth provider you are using in your application. Refer user-meta data on how to enable these fields.

Once enabled, you should be able to access these fields from your user object.

You can enable Authentication Trigger which will run the function when the user sign-up and save those details in your user collection. You can look at Task Tracker Tutorial in your preferred Tech Stack for the same functionality.

I hope the provided information helps.

Cheers, :performing_arts: