Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Hide fields based on roles View modes: 
User avatar
Member
Member
chris.perks-priocept - 3/2/2011 11:53:18 AM
   
Hide fields based on roles
Hi,

My problem is fairly simple - I have a 'Limited Content Editor' role, and want users under that role to be restricted from editing certain fields of certain items on the tree.

Hiding entire items or portions of the tree based on role is something which I'm comfortable doing, however, how can I hide (or make read-only) certain fields within a page editing screen?

I have a hunch I should use Alternate Forms (to specify which fields *should* be shown), however I'm unsure how to tie a particular Alternate Form to a role.

Many thanks,
Chris.

User avatar
Member
Member
martinagency - 3/2/2011 6:46:16 PM
   
RE:Hide fields based on roles
I'm sure their are some grand ways to do this in Kentico, but I would recommend using Alt Forms. You can place all the alt forms on a page and set them to be visible based on role. I hope this helps a little bit.

User avatar
Member
Member
kentico_michal - 3/3/2011 3:35:50 AM
   
RE:Hide fields based on roles
Hi Chris,

Regrettably, this could be done only by creating a new form page (Site manager -> Development -> Document types -> select document type -> General -> Editing form). This page could contain standard cms:form control and as Martin has already suggested you could set AlternativeFormFullName property of the control based on a role of the current user.

Michal Legen,
Best regards

User avatar
Member
Member
chris.perks-lastexit - 3/3/2011 11:15:59 AM
   
RE:Hide fields based on roles
Hi guys,

Thanks! I followed your advice and have it working. The only thing which I have left is, retrieving the Role name for a user.

I'm using Kentico v5.0.3742 and we have:

CMSContext.CurrentUser.IsInRole(..), however I need something like:

String[] myRoles = CMSContext.CurrentUser.Roles;

Is there a way I can find this information?

Thanks!

User avatar
Member
Member
chris.perks-lastexit - 3/3/2011 11:46:56 AM
   
RE:Hide fields based on roles
I must have had temporary blindness -

CMSContext.CurrentUser.SitesRoles

Gives me exactly what I want.

Thanks again guys!

Chris.