Editing Users
Editing a user is as simple as passing a user_id and the user data to update_user(). $data may be an object or an array. Only the information you give is updated, and what information you do give overwrites what is currently stored. Just like with add_user(), BitAuth is able to determine whether the information you are updating is in the users table or the data table.
$this->bitauth->update_user($user_id, $data)
A good example of how this works is found in $this->bitauth->activate():
/**
* Bitauth::activate()
*
*/
public function activate($activation_code)
{
$query = $this->db->where('activation_code', $activation_code)->get($this->_table['users']);
if($query && $query->num_rows())
{
$user = $query->row();
return $this->update_user($user->user_id, array('active' => 1, 'activation_code' => ''));
}
return FALSE;
}
This can be combined with Fetching Users to quickly and easily update user information:
$user = $this->bitauth->get_user_by_username('testuser');
// Remove user from all groups
$user->groups = array();
$this->bitauth->update_user($user->user_id, $user);
For a list of all user fields, see Fetching Users.
Disabling/Deleting Users
Users who are disabled will not be able to login, are removed from all groups, and aren't returned by get_users() or get_groups() (see Fetching Users for information on overriding this).
Users who are deleted, in addition to being disabled, also have their corresponding row deleted in the data table (bitauth_userdata). Essential information (user_id and username) should be kept for posterity.
$this->bitauth->enable($user_id)
Enables a user:
$this->bitauth->enable(2);
$this->bitauth->disable($user_id)
Disables a user:
$this->bitauth->disable(2);
$this->bitauth->delete($user_id)
Deletes a user:
$this->bitauth->delete(2);