I have hundreds of registered users. Those are grouped in different user groups:
See screenshot below (I changed this a little bit to protect my customers site):
- Registered -> Teachers
- Registered -> Students
How can I show a list of 'Teachers' online?
I want to list up all those teachers in a table or list, so that other teachers see this information.
Thank you. Any information is welcome.
You can use the following for to get the usernames from a specific user group:
$teachers = JAccess::getUsersByGroup(2); //change number in the brackets
$students = JAccess::getUsersByGroup(8); //change number in the brackets
foreach($teachers as $user_id) {
$user = JFactory::getUser($user_id);
echo $user->name;
}
foreach($students as $user_id) {
$user = JFactory::getUser($user_id);
echo $user->name;
}
Change "2" and "8" to the ID's of the Teachers and Students user groups.
Hope this helps
Personally, I think the best way to do that is to create a contact category teachers and then link each teacher to a contact record.
You can make a list of users in a group (there's even a method JAccess::getUsersByGroup() but I don't think it's that useful for this purpose. http://officialjoomlabook.com/school25/staff-directory is an example of where I did what I am suggesting.