function user_block_user_action

7.x user.module user_block_user_action(&$entity, $context = array())

Blocks the current user.

Related topics

4 string references to 'user_block_user_action'
drupal-6.bare.database.php in drupal/modules/simpletest/tests/upgrade/drupal-6.bare.database.php
Bare installation of Drupal 6.17, for test purposes.
drupal-6.filled.database.php in drupal/modules/simpletest/tests/upgrade/drupal-6.filled.database.php
Filled installation of Drupal 6.17, for test purposes.
TriggerUserActionTestCase::testUserActionAssignmentExecution in drupal/modules/trigger/trigger.test
Tests user action assignment and execution.
user_action_info in drupal/modules/user/user.module
Implements hook_action_info().

File

drupal/modules/user/user.module, line 3656
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'];
  }
  // If neither of those are valid, then block the current user.
  else {
    $uid = $GLOBALS['user']->uid;
  }
  $account = user_load($uid);
  $account = user_save($account, array('status' => 0));
  watchdog('action', 'Blocked user %name.', array('%name' => $account->name));
}