Dev:Retrieving Users
From Habari Project
Contents |
Current user
You can retrieve the current user, who could be anonymous.
$user = User::identify();
Groups
Users can be retrieved through group membership.
$usergroup = Usergroups::get(array('name'=>'authenticated')); // Get a list of ids $user_ids = $usergroup->members; // Get the actual users $users = $usergroup->users;
Parameters
Basic info
Users can also be retrieved by any database field (username, email, id).
$users = Users::get(array('username' => 'admin'));
Info records
As for posts, additional information can be stored for users. If you store a user's hometown in a userfield called 'hometown', you can access users from Chicago this way:
$users = Users::get( array( 'info' => array( 'hometown' => 'Chicago' ) ) );