JAccess :: getUsersByGroup,如何检查用户是否在joomla中激活并按名称字母顺序排序 [英] JAccess::getUsersByGroup, How to check is user activated in joomla and sort it alphabetical by name

查看:120
本文介绍了JAccess :: getUsersByGroup,如何检查用户是否在joomla中激活并按名称字母顺序排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a problem which I can't solve. What I need is list all activated Joomla users. I found and modifed this code:

    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()不会按名称对用户进行排序(可能是按登录对用户进行排序?).

But this solution has two bugs which I can't fix: - first: this showing unactive (not activated) users too, - secound: asort() don't sort users by name (probably it's sort users by login?).

诚挚的问候.

推荐答案

在这里,请查看注释以了解:

Here you go, check comments to understand:

    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);

这篇关于JAccess :: getUsersByGroup,如何检查用户是否在joomla中激活并按名称字母顺序排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆