Show Hide Existing Ribbon Options / Commands…

Once I wanted to hide some ribbon options for a given permission set. Basically, in SharePoint 2010 the rich text content area allows to insert web part directly on it. I wanted to security trim so, only the users that has Contributor permission level or higher would be able to perform the web part insert.

While figuring out how to do this, I came across an option that, to create a new custom control to perform the show hide ribbon options.

1) Create a custom control (inheriting from System.Web.UI.Control)

2) Override the OnPreRender method

3) Retrieve the ribbon from the current viewing page.

SPRibbon ribbon = SPRibbon.GetCurrent(Page);

Continue reading