function party_user_user_update in Party 8.2
Same name and namespace in other branches
- 7 modules/party_user/party_user.module \party_user_user_update()
Implements hook_user_update().
Performs the email synchronisation.
File
- modules/
party_user/ party_user.module, line 468 - Support for linking users to parties
Code
function party_user_user_update($edit, $account, $category) {
if ($category != 'account') {
// We only want to deal with account, as that is where mail is.
return;
}
// Get our array of fields to update
$fields = variable_get('party_user_email_sync_fields', array());
// Check that we have some fields to work with to avoid unnecessary loads
if (count($fields) > 0 && ($party = party_user_get_party($account))) {
// Iterate over our fields
$data_sets = array();
foreach ($fields as $data_set => $field) {
list($data_set, $field) = explode(':', $field);
if (!isset($data_sets[$data_set])) {
// Load the entity, assume there's only one
$data_sets[$data_set] = reset(party_get_attached_entities($party, $data_set));
}
if ($data_sets[$data_set]) {
// Update the field and save
$data_sets[$data_set]->{$field}[LANGUAGE_NONE][0]['value'] = $account->mail;
$data_sets[$data_set]
->save();
}
}
}
}