function user_unblock_user_action
Unblocks a specific user or the current user, if one is not specified.
Parameters
$entity: (optional) An entity object; if it is provided and it has a uid property, the user with that ID is unblocked.
$context: (optional) An associative array; if no user ID is found in $entity, the 'uid' element of this array determines the user to unblock.
Related topics
1 call to user_unblock_user_action()
- UserActionsTest::testUserBlockUnBlockActions in modules/
user/ user.test - Tests user block and unblock actions.
File
-
modules/
user/ user.module, line 3825
Code
function user_unblock_user_action(&$entity, $context = array()) {
// First priority: If there is a $entity->uid, unblock 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;
}
// The anonymous user should not be unblocked.
if ($uid == 0) {
watchdog('action', 'Anonymous user should not be unblocked.', array(), WATCHDOG_WARNING);
return;
}
$account = user_load($uid);
$account = user_save($account, array(
'status' => 1,
));
watchdog('action', 'Unblocked user %name.', array(
'%name' => $account->name,
));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.