zenben1126 zenben1126 - 29 days ago 17
Javascript Question

How do I extend User model in Meteor?

I have been researching this for ages and cannot find a clear explanation. My meteor app has user accounts installed and logging in/out is all working just fine. However, I'd like to add some optional fields to my users, such as age, gender, etc. How do I go about doing this? Please note, I am new to Meteor so please be explicit.

Answer

To add more fields to the user registration form provided by useraccounts packages, see Form Fields Configuration section of the official Guide

Supposing you want to add a gender field to the registration form, you could do something like this

AccountsTemplates.addField({
  _id: "gender",
  type: "select",
  displayName: "Gender",
  select: [
    {
      text: "Male",
      value: "male",
    },
    {
      text: "Female",
      value: "female",
    },
  ],
});
Comments