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.
Asked
Active
Viewed 3,526 times
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
Aakash Maurya
- 8,481
- 4
- 42
- 74
Arsalan Adam Khatri
- 14,531
- 3
- 36
- 59
-
This is good if you need to activate multiple features. – Hugh Wood Nov 06 '12 at 14:21
-
WebProvisined is web scoped i need site scope event – ozdogan Nov 06 '12 at 14:23
1
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>
Hugh Wood
- 6,285
- 1
- 26
- 45
-
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 06 '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 06 '12 at 14:17
-
2Not 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 06 '12 at 14:27