Blocks the current user.
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,
));
}