Prev |  | Next

## 3.10. User data handling

### 3.10.1. user_save

This hook can be used to handle the data that is going to be stored in the database for a user. Modules can do some last minute change on the data or keep some external system in sync with the Phorum user data.
In combination with the ??? hook, this hook could also be used to store and retrieve some of the Phorum user fields using some external system.

Call time:

Just before user data is stored in the database.

Hook input:

An array containing user data that will be sent to the database.

Hook output:

The same array as the one that was used for the hook call argument, possibly with some updated fields in it.

Example code:

    function phorum_mod_foo_user_save($user)
    {
        // Add "[A]" in front of admin user real_name fields.
        $A = $user["admin"] ? "[A]" : "";
        $real_name = preg_replace('/^\[A\]/', $A, $user["real_name"]);
        $user['real_name'] = $real_name;

        // Some fictional external system to keep in sync.
        include("../coolsys.php");
        coolsys_save($user);

        return $user;
    }

Prev | Up | Next
| Home |