Help with users API

Permalink
Hello
I have scoured the forums and internet looking for an answer/example.
I have successfully used the basics of the Users API to get the name of the current logged in user .
I would like to find a way to loop through and list all the logged on users.
I can't seem to figure out how to do that.
I tried a php/mysql loop , getting the name and id, then did a getUserName but I can't get it to work with a param, used the name returned in the query and look up through.
But it acts like everyone is logged in.

How do you loop through the users and only keep the logged in ones.

I hope this is not to hard an answer. I am lazy

Thanks for the help

Elbert Dee

 
jordanlev replied on at Permalink Reply
jordanlev
elbertdee replied on at Permalink Reply
Thanks

Ill have to read thru
I am an old programmer (started when you still punched cards) turned tech support and still gaining understanding about API and classes.
Just gotta better understand how to use.

I looked and read but had no understanding of how to use to get the list of logged in users.
Ill keep looking till I get it.

Thanks

Elbert
elbertdee replied on at Permalink Reply
Are there any code example of using the api just a couple of short example of php code.
The API is still a black box, sorta. I can check if a user is logged in and this good.

Thanks for the help.

Elbert
jordanlev replied on at Permalink Reply
jordanlev
According to that doc page, you do this:
Loader::model('user_list');
$ul = new UserList();
$users = $ul->get();

Now your $users variable contains a list of all users, which you need to loop through with a foreach loop. Each item in the $users list will be an object that you'll need to access properties of to get the info you need. For example:
foreach ($users as $u) {
  echo $u->getUserName();
}


Seehttp://www.concrete5.org/documentation/developers/permissions/users... for a list of all available properties of the user object. Note that there's a weird thing where some of the user info is in the user object but other info is in the "userInfo" object -- it's all in that docs page. If that page doesn't make sense, I'd suggest brushing up on general PHP first (outside of Concrete5).

Best of luck.
elbertdee replied on at Permalink Reply
Hello jordalev,

Thanks
That was of immense help!

Elbert