SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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

Here is the article that explains event handlers: Implement SharePoint 2010 Site event receivers

Programmatically activating features

And here is the List of Feature GUID's

share|improve this answer
This is good if you need to activate multiple features. – Hugh Wood Nov 6 '12 at 14:21
WebProvisined is web scoped i need site scope event – ozdogan Nov 6 '12 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="">
    <FeatureSiteTemplateAssociation Id="21e613ec-e03f-4499-b1a4-3095d5786b29" TemplateName="SPSPERS#0" />
share|improve this answer
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 '12 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 '12 at 14:17
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 – SPArchaeologist Nov 6 '12 at 14:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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