This project is read-only.

Privatizing the individual post

Topics: Business Logic Layer
Mar 1, 2011 at 10:54 PM

I am new to BlogEngine.Net. I have just integrated BlogEngine to our existing website. It seems that blogs created by anyone can be seen by everyone who has access to the system. But what I want is blogs created by any user should be visible to himself only. No one else can see the post created by him except the administrator. Is there a way to do so? 

FYI, I am using AspNet membership provider. 

Thanks in advance.

Mar 2, 2011 at 7:50 PM

This feature does not exist out of the box as it defeats the nature of the blog ( one writes a post to others, not to him/herself).

However, you may take a try with BE.NET 2.0 Roles and

1) Introduce a new role, lets call it Authenticated Users, and define the rights for this role the way you want.
2) Remove permissions from Anonymous role.
3) If this is not sufficient, you should take a look at BusinessLogic => Post.cs => IsVisible Property

Mar 2, 2011 at 9:16 PM

I agree with you mvincic regarding blogs being public. But it was one of the requirement for my project as of now. I already tried the option number 1 and 2 and it didn't work for me. I will now go for option 3.

Suppose userA writes a blog and userB also writes a blog. When I login as any of the user, I can see all the blogs in my frontpage or the home page from both userA and userB. Shouldn't that be somewhat separated like 'MyBlog' and 'Public Blog'? This is somewhat confusing to me.  

Mar 3, 2011 at 6:33 AM
Edited Mar 3, 2011 at 6:34 AM

It seems that you are looking for multiple blog feature, that does not exist at this moment, and I guess roles / rights system introduced in BE 2.0 is a step in this direction.
What you can do, is to have separate BE.NET installation for each user ( i.e. one  for userA and another for userB).

Mar 3, 2011 at 5:16 PM

Thats right. Till now I was thinking multi-author feature means multiple blog feature.  It might not be a good option to use separate BE.NET installation as there will be lots of users in our application.

We have been using BlogEngine since 2 weeks and we liked every feature it provides. I hope we will get to use to multiple blog features soon. Is there any tentative time that this feature will be available?

Thanks mvincic for providing me directions.




Mar 9, 2011 at 9:54 PM

As of now we decided to go with the current version of BlogEngine.Net as it provides most of the features we need. We realized that unless we can hide individual post of author from another author's, it works perfect for our requirement. Being said that I added the following piece of code in the IsVisible method and was able to privatize the individual post from other authors, however provided the admin to access posts.

public bool IsVisible
                if (this.IsDeleted)
                    return false;

               else if (Security.IsAuthenticated && Security.CurrentUser.Identity.Name.Equals(author, StringComparison.OrdinalIgnoreCase) || Security.IsAdministrator )
                    return true;

                return false;
It seems to be working fine on the main dashboard meaning logged in user can view only their posts if there is any. However when the author hits the "Posts" link in the "Administration" widget then he can see all the posts created by other users.
I need only the list of posts for current logged on use in that grid view(url: /admin/Posts/Posts.aspx/). I don't have any clue as of yet where and how should I modify the code.
Any suggestions would be really helpful.