Print All Users - Joomla 2.5

巧了我就是萌 提交于 2019-12-01 08:15:45
Rakesh Sharma

you can do this run the query on your page where you want to show user list. you can fetch all users table field with $row object.

$db =& JFactory::getDBO();
$query = "SELECT * FROM #__users" ;
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
  echo $row->id.'|'.$row->username.'|'.$row->email;
}

Edit 1

Below is what I used.

Installed extension Flexi Custom Code.

Create module using this, add above code in it and appear that menu on the menu where you want to display.

You'll need some sort of component for this. This user profile component for example (N.B. Using this as my example as a work colleague once used it - not as customizable as I would have liked - but probably OK for what your after. I'm sure there are more as there's an entire member list category.)

Just install one of them and choose what you want to show. Add it to a menu like any other component and off you go!

Two possible solutions

  • Use the User Profile Component available in JED
  • Enable "User - Contact Creator" plugin to create a Contact profile for each new user and then use the Joomla built-in Menu Item to list all contacts
breaker

// my example with opt-groups, preselected user and better user-ids

function getUserList ($user_id) {
    $db = JFactory::getDBO ();
    $db->setQuery ("SELECT id, username, usertype FROM ' . $db->quoteName ('#__users') . ' ORDER BY usertype,username ASC");
    $rows = $db->loadAssocList ();
    static $opt_tag;

    $list = '<option value="0">' . JText::_ ('SELECTION') . '</option>';

    foreach ($rows as $row) {
        if (empty ($opt_tag) || $opt_tag != $row['usertype']) {
            $list .= '<optgroup label="' . $row['usertype'] . '">';
            $opt_tag = $row['usertype'];
        }

        if ($row['id'] < 10) {
            $id = '000' . $row['id'];
        }

        elseif ($row['id'] < 100) {
            $id = '00' . $row['id'];
        }

        elseif ($row['id'] < 1000) {
            $id = '0' . $row['id'];
        }

        $list .= '<option value="' . $row['id'] . '"' . (((int) $user_id == $row['id']) ? ' selected="SELECTED"' : '') . '>' . $id . ' - ' . $row['username'] . '</option>';
        if (empty ($opt_tag) || $opt_tag != $row['usertype']) {
            $list .= '</optgroup>';
        }
    }
    return $list;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!