Have you only got the author? Not the entry itself? From the entry it is just ((UserAuthor)eentry.Blog.Author).User (will need cast an null checks). I suppose you mean author and not Owner, Owner is most probably the MyPage for a personal blog.
I've got both the entry and the current user. We have multiple users posting in one blog, but want the signature to say it's the "owner" of the blog that has posted. Even if we do it from moderation mode, it's still the logged in user that's posted as the author.
What I need to get is the blog's original user, not the current logged in user. But I can't figure out how to get it through the info that's available in the entry object.
Well, that should be the Blog.Author so you can use code similar to my previous example. If the Blog.Author is not the user you want, then perhaps it should be changed? It is what that property is for.
Hi again
That worked, thanks! But I ran into a different problem. I need to determine the BlogType that the entry is in. Do you know how to do that also? I really epreciate your help.
/Peter
Funny, I ran into the same problem myself just the other day. Turns out I could figure it out from the Blog.OwnedBy.Context . Here's my extension method:
public static BlogType GetBlogType(this Blog blog)
{
if (blog == null) throw new ArgumentNullException("blog");
if ((blog.OwnedBy != null) && !String.IsNullOrEmpty(blog.OwnedBy.Context))
{
switch (blog.OwnedBy.Context)
{
case "Blog":
return BlogType.UserBlog;
case "GuestBook":
return BlogType.UserGuestBook;
case "NewsBlog":
return BlogType.ClubNews;
case "MessageBlog":
return BlogType.ClubMessage;
case "ExpertBlog":
return BlogType.ExpertBlog;
}
}
return BlogType.General;
}
Hi!
I can get the author of an entry, but how do I access the owner of the blog that the entry is in?
/Peter