This project is read-only.

Role - Block user from deleting categories in Posts.

Topics: ASP.NET 2.0, Controls
Apr 20, 2011 at 2:43 AM
Edited Apr 20, 2011 at 4:39 AM

In User Roles, is it possible to deny users the ability to delete categories that are listed under Posts?

Apr 21, 2011 at 2:52 PM
Edited Apr 21, 2011 at 2:59 PM

I am hoping this is possible.  Does my question make sense?

If I allow someone else to register for my site and make posts, I don't want that user to be able to delete Categories that are associated with posts because I filter/navigate my site by category.

Apr 22, 2011 at 1:11 PM

It looks like currently, if a user is in a role that has the right to Create posts, then the user can also access the Categories page ... where he can Edit and Delete categories.

Assuming that these users are not in a role that has the right to "Access Admin Settings Pages", then you can add a single line of code to /admin/Posts/Categories.aspx.cs that would prevent anyone who doesn't have the right to "Access Admin Settings Pages" from using that page.  In that Categories.aspx.cs file, line 21 is the following line of code.  If you add the bolded line shown below it, then these users won't be able to access the Categories page.  They will still have a link to it, but will be kicked out when attempting to access the page.  Of course, you can test it yourself to make sure by logging in under an account that is tied to the same role these other people are in.

Apr 24, 2011 at 8:17 PM

BenAmada. This worked perfectly. Thank you very very much for your reply. :)