Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
add comment

2 Answers

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" />
</Elements>
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
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 –  SPArchaeologist Nov 6 '12 at 14:27
add comment

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
add comment

Your Answer

 
discard

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.