Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 30 Dec 2010, 23:48
Hornstar's Avatar
Hornstar Hornstar is offline
 
Join Date: Jun 2005
Real name: Matt
list all users of a usergroup

How would I list all users from a usergroup?
Reply With Quote
  #2  
Old 31 Dec 2010, 00:11
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.
Reply With Quote
  #3  
Old 31 Dec 2010, 00:24
Hornstar's Avatar
Hornstar Hornstar is offline
 
Join Date: Jun 2005
Real name: Matt
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.
Reply With Quote
  #4  
Old 31 Dec 2010, 01:21
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
OK, sorry - I guess that's why you posted in the Programming Discussion area.

Anyway, I think you want something like this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View 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).
Reply With Quote
  #5  
Old 31 Dec 2010, 01:38
Hornstar's Avatar
Hornstar Hornstar is offline
 
Join Date: Jun 2005
Real name: Matt
[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)

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

However not sure which is the best way to get multiple usergroups listed. You mentioned "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."
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.

Last edited by Hornstar; 31 Dec 2010 at 01:53.
Reply With Quote
  #6  
Old 31 Dec 2010, 01:46
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
I could do that. But I also remembered, what you want pretty much already exists in showgroups.php (like this: http://www.vbulletin.org/forum/showgroups.php)

Edit: posted this before I saw your edit above.

--------------- Added 31 Dec 2010 at 01:50 ---------------

Originally Posted by Hornstar View Post
You mentioned "[/B][/COLOR]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."
Could you give me an example of that.

Thanks again.
An example of which way, the second one?

The first way is easier off the top of my head:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


but again I haven't tried it so hoepfully there aren't any syntax errors.

Last edited by kh99; 31 Dec 2010 at 01:55. Reason: Auto-Merged DoublePost
Reply With Quote
  #7  
Old 31 Dec 2010, 01:56
Hornstar's Avatar
Hornstar Hornstar is offline
 
Join Date: Jun 2005
Real name: Matt
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.
Reply With Quote
  #8  
Old 31 Dec 2010, 01:57
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
So which method you feel will do the above best will be fine.
See above...

Originally Posted by Hornstar View Post
Also is there a way to get it to list people in both primary and secondary?
That might take a little while, I don't know how to do that offhand.

Last edited by kh99; 31 Dec 2010 at 01:59. Reason: Auto-Merged DoublePost
Reply With Quote
  #9  
Old 31 Dec 2010, 02:00
Hornstar's Avatar
Hornstar Hornstar is offline
 
Join Date: Jun 2005
Real name: Matt
I missed your reply before, trying that now. one sec. Will edit this when I am done. Thanks.

Edit: yeah that worked great

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


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.

Last edited by Hornstar; 31 Dec 2010 at 02:09.
Reply With Quote
  #10  
Old 31 Dec 2010, 02:48
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
OK, it turned out to be pretty easy (thanks to the code in showgroups.php):


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View 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.

Originally Posted by Hornstar View Post
If you work out how to get it to work with primary and secondary you will be legendary.

Well, not so much legendary, more like 'too much free time', but anyway...

Last edited by kh99; 31 Dec 2010 at 03:03.
Reply With Quote
  #11  
Old 31 Dec 2010, 03:07
Hornstar's Avatar
Hornstar Hornstar is offline
 
Join Date: Jun 2005
Real name: Matt
Thanks!

I'd stick with legendary...I spent hours and hours trying to do this on my own. I even looked through the showgroups and it was just all past me.

Now that I have this, I can easily copy and paste the list of names from a specific usergorup and use it to tag all users from a usergroup (Dbtech tag mod) or send them all a pm, etc.

So thanks again.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 09:08.

Layout Options | Width: Wide Color: