Get Author for User

Vote:
 

This might be a bit of n00b question, but I am upgrading a community from 3 -> 4 and I only have limited experience with 4.

I am a little unsure of what is best practice when it comes to getting the author for a user. the GetUserAuthor method has been removed from the API as far as I can see.

I have found a way, but it not really elegant at all:

var authors = AuthorHandler.Instance.GetAuthors(MyUser);
if(authors.Count > 0)
userAuthor = authors[0];
else
userAuthor = new UserAuthor(MyUser);

 

Anyone out there with a better solution?

 

 

#61150
Sep 10, 2012 8:22
Vote:
 

Do you actually need to get the author like that at all?

The way the authors are handled I would think just "new UserAuthor(user)" is probably all you need for most situations.

 

If you actually need a commited instance (eg if you need to get at its ID in your own code) you can do something like "var author = AuthorHandler.Instance.ChangeAuthor(null, new UserAuthor(user))" which will fetch the existing author or commit a new author for the user as necessary.

#61789
Oct 02, 2012 10:05
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.