Drupal 7. Drupal 6 had a way to configure a rule to check for disallowed words inside the body or subject line of a private message.
I am trying to adapt that rule to Drupal 7. The purpose of this check is to send a warning message to the sender (email or private message) if banned words are found in his message. This can be expanded to various actions, including a temporary ban then a permanent ban if the user persists.
Here is an export of the first rule (but I can't get it to work:)
{ "rules_warning_to_privatemsg_sender_about_curse_words_" : {
"LABEL" : "Warning to privatemsg sender about curse words.",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "rules_i18n", "privatemsg_rules" ],
"ON" : { "privatemsg_insert" : [] },
"IF" : [
{ "text_matches" : {
"text" : [ "privatemsg-message:body" ],
"match" : "word1|word2|word3",
"operation" : "regex"
}
}
],
"DO" : [ { "drupal_message" : { "message" : "Bad word!", "type" : "warning" } } ]
}
}
Word1, word2, and word3 are the words to check for. They are separated by the "|" (pipe or vertical bar) character.
This format was agreeable with Drupal 6 but I am not sure if that still works with Drual 7.
UPDATE: After studying the Regex website, I was able to get the rule to work changing the expression. See my answer below.