I am using accounts-ui for login and registration in MeteorJS.
I want to add a role,on every newly registered user. I am using onCreateUser but it is throwing error Exception while invoking method 'createUser' Error:insert requires an argument Here is, what i am trying..
Accounts.onCreateUser(function(options, user) {
Roles.addUsersToRoles(user._id, ["Student"]);
return user;
});
I had the same problem. I use this code for adding default roles:
Accounts.onCreateUser(function(options, user) {
if (options.profile) {
user.profile = options.profile;
}
user.roles = ['student'];
return user;
});