Are we able to code an event receiver on site collection creation? I have so custom site definitions, i do everything with features. So i need to activate a feature on site collection creation.

2 Answers 2


You have few events and you can write Event Receiver for WebProvisioned

Programmatically activating features

And here is the List of Feature GUID's

  • This is good if you need to activate multiple features.
    – Hugh Wood
    Nov 6, 2012 at 14:21
  • WebProvisined is web scoped i need site scope event
    – ozdogan
    Nov 6, 2012 at 14:23

You can use feature activated, you then fire the feature off with feature stapling on the template.

[update] To activate publishing infrastructure for example:

<?xml version="1.0" encoding="utf-8" ?>
    <Elements Id="fa899b9d-85dd-4e0b-82d1-7cf7f6577136" xmlns="http://schemas.microsoft.com/sharepoint/">
    <FeatureSiteTemplateAssociation Id="21e613ec-e03f-4499-b1a4-3095d5786b29" TemplateName="SPSPERS#0" />
  • no i couldnt explain my question properly i guess. the feature i want to activate (on site collection creation) is not a feature i developed. it is a sharepoint feature that can be activated by powershell.
    – ozdogan
    Nov 6, 2012 at 14:15
  • Then use feature stapling, webprovisioned, or create a new template which activates the feature. If you don't need to run feature activated then you just need to link the feature with the template, so when the template is used it adds the feature to the site automatically.
    – Hugh Wood
    Nov 6, 2012 at 14:17
  • 2
    Not posting this as an answer because feature stapling was already sugested, but have a look at this answer I wrote in the past. It sums the concept of feature stapling pretty well, I belive. Link here
    – SPArcheon
    Nov 6, 2012 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.