JAMESSTONEco
JAMESSTONEco

Reputation: 2051

How can I access another users (not current user) profile from the userId in Meteor?

I doing the following. Adding the current users id as userId in a collection as the author. I would like to be able to access other information in that users (not necessarily the logged in users but could be) so that I could display a profile page. The only work around I have found is to just duplicate the fields from the profile and place them in the collection.

This seems to be less than ideal. Is there a way to access this directly? I am using autopublish so I don't think there should be any permission issues. I am also using iron-router so ideally I would have a route set up like:

Router.map(function() {
  ...
  this.route('profile', {path: '/profile', data: function() { this.params._id}});
});

Upvotes: 0

Views: 122

Answers (1)

richsilv
richsilv

Reputation: 8013

If you've got autopublish on, then Meteor.users.findOne({_id: 'USERID'}) will give you that user's profile. Obviously, if you turn off autopublish you'll have to work out what information to publish.

Upvotes: 1

Related Questions