BitAuth User Guide Version 1.0


How does it work?

Users can be members of one or many groups. Roles are assigned to a group. When a user is a member of a group, he or she inherits all roles of that group. If a user is a member of multiple groups, he or she inherits all of the combined roles of those groups.

Checking Roles

$this->bitauth->has_role($slug, $mask = NULL)

Checks whether a user or group has a role. If $mask is NULL, the currently logged in user is assumed.

Checking the current user

if($this->bitauth->has_role('can_edit'))
{
    echo "Current user has 'can_edit' role.";
}

Checking another user

$user = $this->bitauth->get_user_by_username('testuser');

if($this->bitauth->has_role('can_edit', $user->roles))
{
    echo "User 'testuser' has the 'can_edit' role.";
}

Checking a group

$group = $this->bitauth->get_group_by_name('Test Group');

if($this->bitauth->has_role('can_edit', $group->roles))
{
    echo "Users in group 'Test Group' have the 'can_edit' role.";
}

$this->bitauth->is_admin($mask = NULL)

Check specifically for the administrator role. The $mask parameter of this function behaves exactly like it does in has_role().

if($this->bitauth->is_admin())
{
    echo 'Current user is an administrator.';
}