User List

Permalink 1 user found helpful
Ok, I think im going crazy,
All I need to do is make a list of users on the site, and display a bit of info.

In theory it should just be a simple loop through all of the user accounts, and print the info, but I've read all the documentation, and tried numerous scraps of code, to no avail...

im using this code:
$u = new User();
//echo $u->getUserName();
$username = $u->getUserName();
$ui = UserInfo::getByUserName($username);
$ui->getAttribute('ak_fname'); 
?>
<div class="UserInfoClass">
<label>Username</label>
<div class="UserInfoClassInfo" > 
<?php echo $u->getUserName(); ?></div>
</div>
<?php
$uaks = UserAttributeKey::getPublicProfileList();
        foreach($uaks as $ua) { ?>
            <div class="UserInfoClass">


to display info about the current user, surely i should just be able to adapt it to loop though for every user?

Any help would be greatly appreciated! :)

calumk
 
olliephillips replied on at Permalink Reply
olliephillips
You need to start with the UserList Object

http://www.concrete5.org/documentation/developers/permissions/user-...

There are various filter methods you might want to use to refine which users you return.

The code below returns an array of UserInfo Objects, you should be able to parse that array to display what you need.

Loader::model('user_list');  
$userList = new UserList(); 
// Filter methods used here
$users = $userList->get();
calumk replied on at Permalink Reply
calumk
Thanks, Thats a great help!

I've never parsed anything before, but ill have a go!
olliephillips replied on at Permalink Best Answer Reply
olliephillips
Calum - its not very different than the code you already had. Try this and you'll be able to adapt it.

<?php
Loader::model('user_list');  
$userList = new UserList(); 
// Filter methods used here
$users = $userList->get();
foreach ($users as $userInfo) {
  print_r($userInfo); // Echo contents of each $userInfo object
  echo $userInfo->uName; // How to access the attributes of each user
}
?>
calumk replied on at Permalink Reply
calumk
Thankyou I managed it using a slightly different method that was better suited to what I needed,
I would post the code, but its laced with javascript now, and is basically unreadable unless you know its exact purpose.

Thankyou!!!
jem1516 replied on at Permalink Reply
Very basic PHP knowledge here, how is it possible to parse the array output into usable information... also, I need to filter the output by user group; thank you!
sethmartin replied on at Permalink Reply
sethmartin
Ollie,

If I was doing something like this in Job, what namespace would I need to use?