You are here

function subuser_block_subusers in Subuser 6

Function to block subusers when a parent is blocked.

Parameters

$uid: [optional] The array of subusers, from subuser_get_subusers(), we're interested in blocking.

1 call to subuser_block_subusers()
subuser_user in ./subuser.module
Implementation of hook_user().

File

./subuser.module, line 474
Allows users of a particular role to create sub user account in another role.

Code

function subuser_block_subusers($subusers = NULL) {
  if ($subusers == NULL) {
    global $user;
    $subusers = subuser_get_subusers($user->uid);
  }
  foreach ($subusers as $uid) {
    $account = user_load(array(
      'uid' => (int) $uid,
    ));

    // Skip blocking user if they are already blocked.
    if ($account !== FALSE && $account->status == 1) {
      user_save($account, array(
        'status' => 0,
      ));
    }
  }
}