Yetanotherforum get logged in users details

262 Views Asked by At

I can get the logged in username from membership system:

// Get user details
var user = Membership.GetUser();
IsLoggedIn = (user != null);

But how do I get things like their avatar, user ID and the rest? Thanks for any help I'm really stuck.

1

There are 1 best solutions below

3
On BEST ANSWER

I'm not 100% which version you're on, so I'm basing this on the v1.9.5 and greater.

var user = Membership.GetUser();

// combined user data takes a membership user and
// will automatically cache repeated requests for user data.
var userData = new CombinedUserData(user);

// get avatar with v1.9.5 and greater
var avatarUrl = this.Get<IAvatar>().GetAvatarUrlForUser(userData);

// get avatar with versions before v1.9.5
var avatarUrl = new YafAvatar().GetAvatarUrlForUser(userData);