The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
list all users of a usergroup
How would I list all users from a usergroup?
|
#2
|
|||
|
|||
I think you just need to use "Search For Users" (under Users in the ACP), and choose the group you want from the drop-down menu.
|
#3
|
|||
|
|||
I was a bit vauge sorry. I meant how would I list all users from a usergroup on a template/page.
eg. I have created a file called users.php and a template called users. I want to list all users from usergroup x, y z like this on the page users.php: Usergroup x: user 1, user 2, user 3 usergroup y: user 1, user 2, user 3 usergroup z: user 1, user 2, user 3 My first thinking was there may be a variable? Is there any variable which can list all users from a usergroup? My second thinking was I need to query the users in the usergroup, and then display it. (I need help on the code for this part if so) Thanks in advance. |
#4
|
|||
|
|||
OK, sorry - I guess that's why you posted in the Programming Discussion area.
Anyway, I think you want something like this: PHP Code:
That does one user group, so you can put that whole thing in a loop, or you could modify the query to get all groups at once and handle the separate lists in the while loop. Also this only handles primary user groups and not membership in secondary groups. (And also I haven't tried this code at all). |
#5
|
|||
|
|||
[strike]Yeah that does look like something I would need. However I can't get it to function just yet.
Maybe I am doing something wrong. Any chance you could test it out (also output 2 usergroups). Thanks again.[/strike] Edit: Got it to work with 1 usergroup now (So big thanks for that) PHP Code:
Could you give me an example of that. Also is there a way to get it to list people in both primary and secondary? Thanks again. |
#6
|
|||
|
|||
I could do that. But I also remembered, what you want pretty much already exists in showgroups.php (like this: https://vborg.vbsupport.ru/showgroups.php)
Edit: posted this before I saw your edit above. --------------- Added [DATE]1293763857[/DATE] at [TIME]1293763857[/TIME] --------------- Quote:
The first way is easier off the top of my head: PHP Code:
but again I haven't tried it so hoepfully there aren't any syntax errors. |
#7
|
|||
|
|||
This is what I am trying to achieve on the page:
Usergroup 4: user1, user2, user 3 etc. Usergroup 9: user2, user 6, user 8 etc. So which method you feel will do the above best will be fine. If possible can you also get it to work with both primary and secondary usergorups. Thanks again. |
#8
|
|||
|
|||
Quote:
That might take a little while, I don't know how to do that offhand. |
#9
|
|||
|
|||
I missed your reply before, trying that now. one sec. Will edit this when I am done. Thanks.
Edit: yeah that worked great Code:
$groups = array("Super Mods" => 5, "Admins" => 6, "Mods" => 7); // set this to the group id you want foreach ($groups as $groupname => $groupid) { $users = $vbulletin->db->query_read("SELECT username FROM ".TABLE_PREFIX."user WHERE usergroupid = $groupid"); $str = ''; $sep = ''; while ($user = $vbulletin->db->fetch_array($users)) { $str .= $sep . $user['username']; $sep = ', '; } // $str is comma separated list of users in $groupid $vbulletin->db->free_result($users); echo "$groupname: $str <BR></BR>"; } The only improvement would be to have it work with both primary and secondary. Gotta say tho, you have been really great If you work out how to get it to work with primary and secondary you will be legendary. Thanks again. |
#10
|
|||
|
|||
OK, it turned out to be pretty easy (thanks to the code in showgroups.php):
PHP Code:
I was thinking of trying to do it the other way so that it would be only one query, but really it's starting to get to the point where it would have been easier to start with showgroups.php. And as long as you're not putting this on your home page or anything, it probably won't make any difference. Quote:
Well, not so much legendary, more like 'too much free time', but anyway... |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|