user_block_user_action

6 user.module user_block_user_action(&$object, $context = array())
7 user.module user_block_user_action(&$entity, $context = array())
8 user.module user_block_user_action(&$entity, $context = array())

Blocks the current user.

Related topics

2 string references to 'user_block_user_action'

File

modules/user/user.module, line 3606
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));
}

Comments

Description needs to be changed

The description of this function should really be changed from

Blocks the current user.

to

Blocks a user.

since it can be used to either block the current user OR some other user depending upon the parameters passed in.

It's description is confusing and scares people away from using it in VBO actions because they assume it means it only works to block the currently logged in user using the VBO--not the results from the VBO View.

Login or register to post comments