function user_block_user_action

Blocks the current user.

Related topics

File

drupal/core/modules/user/user.module, line 2831
Enables the user registration and login system.

Code

function user_block_user_action(&$entity, $context = array()) {

  // First priority: If there is a $entity->uid, block that user.
  // This is most likely a user object or the author if a node or comment.
  if (isset($entity->uid)) {
    $uid = $entity->uid;
  }
  elseif (isset($context['uid'])) {
    $uid = $context['uid'];
  }
  else {
    $uid = $GLOBALS['user']->uid;
  }
  $account = user_load($uid);
  $account->status = 0;
  $account
    ->save();
  watchdog('action', 'Blocked user %name.', array(
    '%name' => $account->name,
  ));
}