Skip to content

Instantly share code, notes, and snippets.

@Cameron-D
Created April 5, 2014 09:38
Show Gist options
  • Save Cameron-D/9989669 to your computer and use it in GitHub Desktop.
Save Cameron-D/9989669 to your computer and use it in GitHub Desktop.

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment