3.18.2. cc_save_user

This hook works the same way as the ??? hook, so you can also use it for changing and checking the user data that will be saved in the database. There's one difference. If you want to check a custom field, you'll also need to check the panel which you are on, because this hook is called from multiple panels. The panel that you are on will be stored in the panel field of the user data.

The example hook belows demonstrates code which could be used if you have added a custom field to the template for the option Edit My Profile in the control panel.

Call time:

In control.php, right before data for a user is saved in the control panel.

Hook input:

An array containing the user data to save.

Hook output:

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

Example code:

function phorum_mod_foo_cc_save_user ($data)
{
    // Only check data for the panel "user".
    if ($data['panel'] != "user") return $data;

    $myfield = trim($data['your_custom_field']);
    if (empty($myfield)) {
        $data['error'] = 'You need to fill in my custom field';
    }

    return $data;
}