How To Enable The Reporting Of Offensive Content In Community Sites

Microsoft has introduced several new features of Community Sites, along with reporting of offensive content in SharePoint 2013. If users of community sites come across any incorrect / inappropriate content (discussion post), they can report that discussion post to moderators for evaluation. Accordingly, moderators can review such content and take the corrective action by either modifying the content or deleting it. For enabling this feature, we need to update the community settings. The steps for enabling this feature are, as follows –

  • Visit Community site.
  • Click on Community settings option from Community tools section.

  • Mark Enable reporting of offensive content checkbox and click on OK button.

  • Once we enable this setting, Report to moderator option will start showing in discussion posts.

  • Now, we need to enable this option using code. Enabling this option using code is not a straight forward solution. We need to use reflection for achieving it. Following is the code snippet for the same.

    1. SPSecurity.RunWithElevatedPrivileges(() =>  
    2. {  
    3. using (SPSite site = new SPSite("<<CommunityWebUrl>>"))  
    4. {  
    5. using (SPWeb web = site.OpenWeb())  
    6. {  
    7. web.AllowUnsafeUpdates = true;  
    8.               web.AllProperties["vti_CommunityEnableReportAbuse"] = "true";  
    9.               web.Update();  
    10.   
    11.               Assembly sharePointAssembly = typeof(Microsoft.SharePoint.Portal.SitePage).Assembly;  
    12.               Type functionalityEnablersType = sharePointAssembly.GetType("Microsoft.SharePoint.Portal.FunctionalityEnablers");  
    13.               MethodInfo methodInfo = functionalityEnablersType.GetMethod("EnableDisableAbuseReports");  
    14. methodInfo.Invoke(nullnew object[] { web, true });  
    15. web.AllowUnsafeUpdates = false;  
    16. }  
    17. }  
    18. });  
Ebook Download
View all
Learn
View all