Dev:Retrieving Users

From Habari Project

Jump to: navigation, search

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' ) ) );
Personal tools
This is a cached copy of the requested page, and may not be up to date.

Sorry! This site is experiencing technical difficulties.
Try waiting a few minutes and reloading.

(Cannot contact the database server: Access denied for user 'habari'@'localhost' to database 'habari_wiki' (localhost))


You can try searching via Google in the meantime.
Note that their indexes of our content may be out of date.