Same name and namespace in other branches
  1. 7.x modules/user/user.module \user_block_user_action()

Implementation of a Drupal action. Blocks the current user.

File

modules/user/user.module, line 2349
Enables the user registration and login system.

Code

function user_block_user_action(&$object, $context = array()) {
  if (isset($object->uid)) {
    $uid = $object->uid;
  }
  elseif (isset($context['uid'])) {
    $uid = $context['uid'];
  }
  else {
    global $user;
    $uid = $user->uid;
  }
  db_query("UPDATE {users} SET status = 0 WHERE uid = %d", $uid);
  sess_destroy_uid($uid);
  watchdog('action', 'Blocked user %name.', array(
    '%name' => check_plain($user->name),
  ));
}