Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

How to add fields to the users?

Open elgriego opened this issue 10 years ago • 33 comments

I would like to add fields to the user registration!

The registration only ask for and user name & email.

I try but I can't do it :S

[UPDATE]

What i try is adding fields in the registerUser.coffe :

userData = email: formData.email password: formData.pass lastname: 'lastName'

But it does not work :S, I get an error on meteor terminal:

Error: A method named 'registerUser' is already defined at livedata_server.js:1542:15 at Function..each..forEach (packages/underscore/underscore.js:113:1) at [object Object]._.extend.methods (livedata_server.js:1538:7) at Object.Meteor.methods (server/lib/debug.js:33:2) at server/methods/registerUser.js:2:1 at server/methods/registerUser.js:22:1

elgriego avatar Feb 22 '16 19:02 elgriego

@RocketChat/core what do you think about this issue?

rodrigok avatar Feb 22 '16 19:02 rodrigok

@elgriego,

Actually, userData (where you're trying to add the lastname) is passed to Accounts.createUser which is a meteor function and which won't save extra data. Just have a look a bit below, I think you can do something like: RocketChat.models.Users.setName userId, formData.name

Johann-Snapp avatar Feb 23 '16 08:02 Johann-Snapp

We should have a way to define extra fields for the registration form (similar to the settings?), but I can imagined it getting much more complex very soon, as admin will want to configure validations, etc.

But I agree, we should have some easy way to add more fields.

engelgabriel avatar Feb 23 '16 12:02 engelgabriel

Related: #2046

geekgonecrazy avatar Jun 14 '16 19:06 geekgonecrazy

related #2048

timkinnane avatar Jul 29 '16 02:07 timkinnane

@RocketChat/core I'm working on this issue with @nazclarion. We're wondering where in mongo is the best place for user field extensions - A) in the user document, B) nested in a property of user (like custom-fields), C) in a seperate collection?

I’m not sure what that means for migrations with different versions / branches. If we populate custom fields then build a version that doesn’t have this package, are there DB migrations that would remove the changes?

Speaking of validations etc, I'd like to work towards a more unified approach to encourage consistency with admin controls and settings pages, which is kinda lacking at present. I've looked into how other Meteor projects do that and found a possible approach, using a few packages together to provide schemas for auto-building forms. Maybe there's some packages already doing this? e.g.

aldeed:simple-schema combined with aldeed:collection2. Then possible to also use aldeed:autoform to generate form UI straight from the collection schema, no template markup required.

OR

More manual, less prescriptive approach could just be providing a front end validator to all packages, something like Parsley.js.

Thoughts?

timkinnane avatar Jul 29 '16 02:07 timkinnane

It would also be useful to have these "About me"/"Role" fields be searchable from a system-wide search feature that searches among all chats and user profiles, so that I could search for expertise within my organization using the search feature.

engelgabriel avatar Aug 18 '16 14:08 engelgabriel

I would also like this feature, synced from ldap. Essentially, the additional fields could be added to 'User Data Field Map' under Admin -> LDAP. Any hints on where to start?

engelgabriel avatar Aug 18 '16 14:08 engelgabriel

@cbrummitt, @VirtuaCreative, @estadtherr, @meilinger, @joetm, @Schoaf, @svenschumacher, @gongled, @jcardila @acaronmd lets use this issue to track your request from https://github.com/RocketChat/Rocket.Chat/issues/2046

engelgabriel avatar Aug 18 '16 15:08 engelgabriel

@timkinnane and @rodrigok can we have a chat about this on our demo server?

engelgabriel avatar Aug 18 '16 15:08 engelgabriel

I agree it is needed, together with #2135 :)

sirchojin avatar Aug 23 '16 10:08 sirchojin

Add fields in registration process was done here https://github.com/RocketChat/Rocket.Chat/pull/4073

rodrigok avatar Aug 23 '16 12:08 rodrigok

+1

chellem avatar Jan 27 '17 14:01 chellem

@RocketChat/core is there anything needed done on this? From what I can tell #4073 should have resolved this.

geekgonecrazy avatar Jan 27 '17 20:01 geekgonecrazy

@geekgonecrazy Documentation on how it works and how to use it.

graywolf336 avatar Jan 27 '17 21:01 graywolf336

https://github.com/RocketChat/Rocket.Chat.Docs/issues/221

engelgabriel avatar Feb 14 '17 15:02 engelgabriel

Hey, i'm trying to add some customFields using the api/v1/users.update method.

It seems that my HTTP calls are successful (e.g. i'm managing to update the "name" field; or add complete new users). nonetheless, it seems that i can't update (or add) customField - as it doesn't appear in the user data on mongoDB.

 var options = {
        url: url +"/api/v1/users.update",
        method: 'POST',
        headers: {
            "X-Auth-Token": credentials.authToken,
            "X-User-Id": credentials.userId,
            "Content-type": "application/json"
        },
        form: {userId: userId, data: {customFields: {twitter:"something"}, name: "ido try"}}
    }
request(options, function(err, res, body) {
        var bodyParse= JSON.parse(body)
        console.log(bodyParse)
    })

shaharido1 avatar Feb 15 '17 12:02 shaharido1

@shaharido1 I'm having the same problem. Were you able to resolve this?

Syirrus avatar Mar 23 '17 13:03 Syirrus

have you guys correctly configured the Custom Fields under Administration > Accounts > Registration?

sampaiodiego avatar Mar 23 '17 14:03 sampaiodiego

@sampaiodiego I have not. I just added the fields manual to my document i.e.

"_id" : "Giek2324dsd", "customFields" : { "situation" : "I was hurt by a person.", "amount" : "50", "isShowing" : false }

So I have to add the custom fields in the admin section and then the API (users.update) will work?

Syirrus

Syirrus avatar Mar 23 '17 14:03 Syirrus