Use API to check if "Bad Words" is enabled

Adam Steffes asked on October 29, 2014 14:34

I've created a custom messaging web part. I need to check if "Check bad words" is turned on in the system settings.

This is a really simple question, but I can't find this simple boolean value in the system. The class BadWordsHelper does not want to provide me with a simple boolean as far as I can tell.

Can someone please enlighten me?

Image Text

Correct Answer

Brenden Kehren answered on October 29, 2014 17:14

Should be able to use this to get the boolean value bool useBadWords = SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSCheckBadWords");

1 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on October 29, 2014 17:18

Should have mentioned it uses the CMS.DataEngine namespace

0 votesVote for this answer Mark as a Correct answer

Adam Steffes answered on October 29, 2014 18:28

Thanks again Brenden, you're a huge help.

0 votesVote for this answer Mark as a Correct answer

Jakub Kadlubiec answered on October 29, 2014 18:45

Another way:

bool useBadWords = CMS.Protection.BadWordsHelper(SiteContext.CurrentSiteName);
1 votesVote for this answer Mark as a Correct answer

Adam Steffes answered on October 29, 2014 19:05

The BadWordsHelper class is static and does not accept parameters in its constructor. I do see a method that does what Brenden indicated inside BadWordsHelper:

 /// <summary>
    /// Indicates if the bad words check should be performed.
    /// 
    /// </summary>
    /// <param name="siteName">Site name</param>
    public static bool PerformBadWordsCheck(string siteName)
    {
      return SettingsKeyInfoProvider.GetBoolValue((SettingsKeyName) (siteName + ".CMSCheckBadWords"));
    }
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.