Wednesday, April 4, 2012

Hide Site Action and Site Settings link

We know there is a straight way to add a Custom action under a Site Actions menu or in a Site settings page. You just need to develop a feature with a custom action and deploy it.

I got a requirement to hide a custom action under the Site Actions menu. I initially thought of doing it in using my familiar JQuery hack and hide dirty way. Then something I found that there is a straight way available in SharePoint. Just develop a feature with a element file and add the below code.

<HideCustomAction
  GroupId = "SiteAdministration"
  HideActionId = "DeleteWeb"
  Id = "HideDeleteWeb"
  Location = "Microsoft.SharePoint.SiteSettings">
</HideCustomAction>
Here in the above code:

GroupId: Self explanatory for a developer. You can find the group id herehttp://msdn.microsoft.com/en-us/library/bb802730.aspx
HideActionId: The id of the custom action that needs to be hidden. This can be found if you search in the features folder(in element file).
Id: Some Unique id(optional).
Location: From Where is should be hidden.
Hope this helps someone.