Saturday, January 31, 2009

Hide Custom Actions

I recently learned about hiding items in SharePoint using the HideCustomAction element.  I had requests to hide items such as the Site Theme, Site Features, and Site Collection Features in Site Settings (I hide all three in my example below).  It is as easy as creating a feature with two XML files.

NOTE: This will remove the links only.  Users will still be able to manually browse to the pages if they know the full URL.  This is not a replacement for security!

 Feature.xml
<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="af6215af-f836-4a09-aa3b-8685981d478f"
Title="Hide Custom Action Links"
Description="This feature currently hides: site features, site collections features, and site themes."
Version="1.0.0.0"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="HideCustomActions.xml" />
  </ElementManifests>
</Feature>

HideCustomActions.xml
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <HideCustomAction
  GroupId="SiteAdministration"
  HideActionId="ManageSiteFeatures"
  Location="Microsoft.SharePoint.SiteSettings"
/>
  <HideCustomAction
  GroupId="SiteCollectionAdmin"
  HideActionId="ManageSiteCollectionFeatures"
  Location="Microsoft.SharePoint.SiteSettings"
/>
  <HideCustomAction
  GroupId="Customization"
  HideActionId="Theme"
  Location="Microsoft.SharePoint.SiteSettings"
/>
</Elements>

John Holliday has a great list of all of the Custom Action IDs on his site: http://johnholliday.net/resources/customactions.html

Jeff

No comments:

Post a Comment