JAccess :: getUsersByGroup,如何检查用户在joomla中激活并按名称按字母顺序排序

时间:2013-09-20 10:38:34

标签: php joomla

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

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

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

亲切的问候W。

1 个答案:

答案 0 :(得分: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);