in blog post comments bad word not applying.

harshal bundelkhandi asked on February 16, 2017 18:16

Hello Support , I am having kentico 9 version website.in that we are using in built blog post & comments section. in that we are not able apply bad words for whole text or sentence to replace or restriction.in the kentico cms setting or code behind.in comment box for single word is restricting but not applying for whole sentence .i am doing bad word checking code behind.

can you suggest some setting or code.

Regards, Harshal

Recent Answers


Charles Matvchuk answered on February 16, 2017 18:41 (last edited on February 16, 2017 18:43)

If you are checking in code behind, See example code below, which works fine as custom code.


var textToSave = XCMFunctions.ProcessCheckAllBadWords(textToCheck);

 public static string ProcessCheckAllBadWords(string textstring)
    {
        // Hashtable that will contain found bad words
        Hashtable foundWords = new Hashtable();

        // Modify the string according to found bad words and return which action should be performed
        BadWordActionEnum action = BadWordInfoProvider.CheckAllBadWords(null, SiteContext.CurrentSiteName, ref textstring, foundWords);

        if (foundWords.Count != 0)
        {
            switch (action)
            {
                case BadWordActionEnum.Deny:
                    // Some additional actions performed here ...
                    break;

                case BadWordActionEnum.RequestModeration:
                    // Some additional actions performed here ...
                    break;

                case BadWordActionEnum.Remove:
                    // Some additional actions performed here ...
                    break;

                case BadWordActionEnum.Replace:
                    // Some additional actions performed here ...
                    break;

                case BadWordActionEnum.ReportAbuse:
                    // Some additional actions performed here ...
                    break;

                case BadWordActionEnum.None:
                    // Some additional actions performed here ...
                    break;
            }

            return textstring;
        }

        return textstring;
    }
1 votesVote for this answer Mark as a Correct answer

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