Feature stapler for MySite to activate the Publishing Infrastructure Feature

Recently, I had worked with another interesting requirement in which customer has some specific requirement with MySites. Their basic requirement was whenever the “my site” get provisioned that time they want to activate the “Office SharePoint Server Publishing Infrastructure feature”.

So, the easiest way that we could accomplish their requirement was using a feature stapler.

<?xml version="1.0" encoding="utf-8" ?>

<Elements Id="fa899b9d-85dd-4e0b-82d1-7cf7f6577136" xmlns=" https://schemas.microsoft.com/sharepoint/ ">

<FeatureSiteTemplateAssociation Id="21e613ec-e03f-4499-b1a4-3095d5786b29" TemplateName="SPSPERS#0" />

</Elements>

Two OOB templates which are involved in MySite creation are SPSPers#0 and SPSMSiteHost#0. First one is for Home and the second one is for Profile – profile site will get created whenever we provision the SSP and it will just take the user account information as query string to show the details , (?people.aspx?domain\username) whenever we click on “My Profile” tab.

We have created a farm level scoped feature to associate the template to the Publishing Infrastructure feature. When this farm level stapling feature get installed, it staples the publishing infrastructure feature with SPSPERS#0 and then after whenever we create any MYSite then the Publishing Infrastructure feature automatically get activated. Also, for profile site since we are using a single site for all the users, we can manually activate it once and it will be available for all other users.

Here are some links which will give more information about MySite customization & Feature stapling.

https://blogs.msdn.com/sridhara/archive/2007/05/19/customizing-mysite-in-moss-2007.aspx

https://msdn.microsoft.com/en-us/library/bb861862.aspx