How to show a list of registered users in Joomla?

2019-09-02 02:37发布

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.

enter image description here

标签: list joomla
2条回答
该账号已被封号
2楼-- · 2019-09-02 03:20

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.

查看更多
相关推荐>>
3楼-- · 2019-09-02 03:30

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

查看更多
登录 后发表回答