function simple_ldap_user_user_update in Simple LDAP 7.2
Same name and namespace in other branches
- 7 simple_ldap_user/simple_ldap_user.module \simple_ldap_user_user_update()
Implements hook_user_update().
Fires when a user account is edited.
Parameters
array $edit: The form values submitted by the user.
File
- simple_ldap_user/
simple_ldap_user.module, line 340 - Main simple_ldap_user module file.
Code
function simple_ldap_user_user_update(&$edit, $account, $category) {
// Don't do anything for uid 1.
if ($account->uid == 1) {
return;
}
// Don't do anything if the hook was called via hook_sync_user_to_drupal().
if (empty($account->hook_sync_user_to_drupal)) {
$ldap_user = SimpleLdapUser::singleton($account->name);
$enabled = isset($edit['status']) ? $edit['status'] : NULL;
// In hook_user_presave, we may have messed with the $edit['status'] and
// $account->status values, setting them to the database values, not what
// LDAP had set status to. Set those back to the LDAP values now.
if (isset($account->simple_ldap_user_ldap_status)) {
$enabled = $account->status = $account->simple_ldap_user_ldap_status;
}
if ($enabled || $ldap_user->exists) {
module_invoke_all('sync_user_to_ldap', $account);
}
}
else {
unset($account->hook_sync_user_to_drupal);
}
}