Anyone using a code to filter out unwanted words in the database fields.
Thanks
Bad word Filter
Re: Bad word Filter
I use the following code in Hook before insert:
The above code will filter any of the 6 words (of course you should write the words your need to filter instead of Word1 etc).
If one these words was detected it will register the word Error in the database instead; as I need to raise an alert in the system.
The error will be accepted only ONCE as it is set as Unique, we will train the user who caused the error, edit the error, and wait for the next one to happen.
Off course you can changed that part and do anything else you want, like return FALSE in order not to register anything in the database etc.
Code: Select all
$product = $data['Product'];
$bannedWords = array('Word1','Word2','Word3', 'Word4', 'Word5', 'Word6');
if(preg_match('#('.implode('|',$bannedWords).')#i', $product)) {
$data['Product'] = 'Error';
If one these words was detected it will register the word Error in the database instead; as I need to raise an alert in the system.
The error will be accepted only ONCE as it is set as Unique, we will train the user who caused the error, edit the error, and wait for the next one to happen.
Off course you can changed that part and do anything else you want, like return FALSE in order not to register anything in the database etc.
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper