0

我有一个我无法解决的问题。我需要的是列出所有激活的 Joomla 用户。我找到并修改了这段代码:

    jimport( 'joomla.access.access' );
    $coaches = JAccess::getUsersByGroup(2);
    jimport( 'joomla.user.user' );
    foreach($coaches as $coaches){
        $coach[$coaches] =& JFactory::getUser($coaches);
    }
    asort($coach);

但是这个解决方案有两个我无法修复的错误: - 首先:这也显示非活动(未激活)用户, - 其次:asort() 不按名称对用户进行排序(可能是通过登录对用户进行排序?)。

向 W 致以亲切的问候。

4

1 回答 1

0

给你,检查评论以了解:

    jimport( 'joomla.access.access' );
    $coaches = JAccess::getUsersByGroup(2);
    jimport( 'joomla.user.user' );

    foreach($coaches as $coaches){

        $users =& JFactory::getUser($coaches);

        //check if user is NOT blocked or NOT activated yet
        if($users->block == '0' && empty($users->activation)){

        //create array not object for better sorting possibilities
        $coach[$coaches] = (array) $users;

       }

    }

    array_multisort($coach, SORT_ASC);
    var_dump($coach);
于 2013-09-20T11:14:49.993 回答