3.9.5. check_post

This hook can be used for modifying the message data and for running additional checks on the data. If an error is put in $error, Phorum will stop posting the message and show the error to the user in the post-form.

Beware that $error can already contain an error on input, in case multiple modules are run for this hook. Therefore you might want to return immediately in your hook function in case $error is already set.

Below is an example of how a function for this hook could look. This example will disallow the use of the word "bar" in the message body.

Call time:

In the include/posting/check_integrity.php file, right after performing preliminary posting checks, unless these checks have returned something bad.

Hook input:

An array containing:

Hook output:

Same as input.

Example code:

 function phorum_mod_foo_check_post ($args) {
    list ($message, $error) = $args;
    if (!empty($error)) return $args;

    if (stristr($message["body"], "bar") !== false) {
        return array($message, "The body may not contain 'bar'");
    }

    return $args;
}