Meteor roles not added to user


Recently I’ve been trying to add roles to my users. I use the useraccount package and the role package.

I configured useraccount to call a function when a new user is created, using the postSignUpHook hook.

In the hook, everything seems to work since I can retrieve the user’s information. But the role is not added in the database. Yet the documentation ensures that this hook is called when a user is successfully created.

What am I doing wrong?

Here is my code:

let myPostSignUpHook = function (userId, info) {
    Roles.addUsersToRoles(userId, 'user', Roles.GLOBAL_GROUP);

    homeRoutePath: '/',
    postSignUpHook: myPostSignUpHook,

PS: Roles are already created.


Roles.setUserRoles(userId, 'user', Roles.GLOBAL_GROUP);

instead of

Roles.addUsersToRoles(userId, 'user', Roles.GLOBAL_GROUP);

1 Like

Thank you @bordalix for your answer but it does not work :neutral_face:

1 Like

Weird, that’s the example on

My code works with that.

Are you running v3? Are you running it on the server side?

1 Like

Ok I was stucked in v2 behavior ! I didnt’ see that I needed to add this in my server code:

Meteor.publish(null, function () {

    if (this.userId) {

        return Meteor.roleAssignment.find({ 'user._id': this.userId });

    } else {




And I was searching in wrong collection.
Ok my bad !

Thank you very much @bordalix

1 Like