How to hide new site option in feature is activated event. when feature is deactivated it will visible to users
1 Answer
You can add following custom action:
<CustomAction
Id="HideCreateSiteInSiteActions"
Location="Microsoft.SharePoint.StandardMenu"
GroupId="SiteActions"
Sequence="901"
Title="Publishing SiteActions Menu Customization"
ControlAssembly="Your Assembly full name" ControlClass="your class full name">
And following code in the Class file:
public class YourClassName : WebControl
{
protected override void OnLoad(EventArgs e)
{
var siteActions = ToolBarMenuButton.GetMenuControl(this);
siteActions.MenuControl.PreRender += (o, args) =>
{
var targetMenu = siteActions.GetMenuItem("MenuItem_CreateSite");
if (targetMenu == null) return;
siteActions.MenuControl.HiddenMenuItems.Add(targetMenu);
};
}
}