You are here

function simple_ldap_user_delete_blocked_user_update in Simple LDAP 7.2

Same name and namespace in other branches
  1. 7 contrib/simple_ldap_user_delete_blocked/simple_ldap_user_delete_blocked.module \simple_ldap_user_delete_blocked_user_update()

Implements hook_user_update().

Deletes a user from LDAP if status is changed to "blocked".

File

contrib/simple_ldap_user_delete_blocked/simple_ldap_user_delete_blocked.module, line 12
simple_ldap_user_delete_blocked module file.

Code

function simple_ldap_user_delete_blocked_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)) {
    if (!$edit['status']) {

      // Delete the user from LDAP if changed to "blocked".
      $ldap_user = SimpleLdapUser::singleton($account->name);
      $ldap_user
        ->delete();
    }
  }
}