Okay, so I'm assuming that is being run from a hook on do_new_reply_start
?
Instead of calling error()
in your code, put in the code from inside Cedric's function:
if(preg_match($regex, $post->data['message'], $match)) {
if(!isset($mybb->cookies['myplugin_errors'])) {
$count = 0;
} else {
$count = $mybb->cookies['myplugin_errors'];
}
$count++;
$expiry = TIME_NOW + (60*60*24); // Expiry = 1 day
my_setcookie("myplugin_errors", "{$count}", $expiry, true);
}
Then you simply need to check if the user has encountered too many errors, and if they have, prevent them from posting. Make a plugin hook to newreply_start (and probably newthread_start), all it needs to do is check if $mybb->cookies['myplugin_errors']
is greater than the limit and it it is, call error_no_permission();