Prev |  | Next

## 3.19. Read messages

### 3.19.1. read

(Phorum 5)

This hook can be used to pre-process all the messages.

Call time:

Right before the countview is incremented and before the messages have been formatted.

Hook input:

The array of messages to be shown and the currently shown message_id. NOTE: the read hook is also used in feed.php but without the $message_id parameter, thus be advised to make the second parameter optional (default to 0), message_id was added in 5.2.15

Hook output:

The array of messages. Data attached to messages can be added (e.g. for specific usage in custom templates). The current message_id cannot be changed that way.

Example code:

    function phorum_mod_foo_read($messages, $message_id = 0)
    {
        // extend all message with some data
        foreach ($messages as &$message) {
            $message['random'] = rand();
        }
        // Do something special with the current message
        if ($message_id > 0) {
            $messages[$message_id]['random'] = 0;
         }

        return $messages;
    }

Prev | Up | Next
| Home |