Prev |  | Next

### 3.11.3. user_get

This hook can be used to handle the data that was retrieved from the database for a user. Modules can add and modify the user data.
In combination with the ??? hook, this hook could also be used to store and retrieve some of the Phorum user fields in some external system

Call time:

Just after user data has been retrieved from the database.

Hook input:

This hook receives two arguments.
The first argument contains an array of users. Each item in this array is an array containing data for a single user, which can be updated.
The second argument contains a boolean that indicates whether detailed information (i.e. including group info) is retrieved.

Hook output:

The array that was used as the first argument for the hook call, possibly with some updated users in it.

Example code:

    function phorum_mod_foo_user_get($user, $detailed)
    {
        // Let's asume that our usernames are based on the
        // system users on a UNIX system. We could merge some
        // info from the password file with the Phorum info here.

        // First try to lookup the password file entry.
        // Return if this lookup fails.
        $pw = posix_getpwnam($user['username']);
        if (empty($pw)) return $user;

        // On a lot of systems, the "gecos" field contains
        // the real name for the user.
        $user['real_name'] = $pw["gecos"] != ''
                           ? $pw["gecos"]
                           : $user["real_name"];

        // If a custom profile field "shell" was created, then
        // we could also put the user's shell in the data.
        $user['shell'] = $pw['shell'];

        return $user;
    }

Prev | Up | Next
| Home |