function role_watchdog_user_save in Role Watchdog 6
Same name and namespace in other branches
- 6.2 role_watchdog.module \role_watchdog_user_save()
- 7.2 role_watchdog.module \role_watchdog_user_save()
- 7 role_watchdog.module \role_watchdog_user_save()
Process role add/remove.
1 call to role_watchdog_user_save()
- role_watchdog_user in ./
role_watchdog.module - Implementation of hook_user().
File
- ./
role_watchdog.module, line 147 - Logs changes to user roles.
Code
function role_watchdog_user_save($uid, &$form, $account) {
// Incoming format: array([2] => authenticated user, [3] => test role,)
$old_roles = _role_watchdog_user_roles_cache($account->uid);
unset($old_roles[DRUPAL_AUTHENTICATED_RID]);
// No built-in roles.
if (!empty($old_roles)) {
$old_roles = array_flip($old_roles);
}
// Outgoing format: array([test role] => 3,)
// Incoming format: array([3] => 3, [2] => 1,)
$new_roles = $form['roles'];
unset($new_roles[DRUPAL_AUTHENTICATED_RID]);
// No built-in roles.
if (!empty($new_roles)) {
$new_roles = array_flip($new_roles);
unset($new_roles[0]);
}
// Outgoing format: array([3] => 3,)
return _role_watchdog_process_role_changes($account, $new_roles, $old_roles);
}