MyBB Community Forums

Full Version: Usergroup Lists
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a template field to list all members of a specific group?
PHP should do it. Even though I have never done it myself, it will work.
(2015-03-04, 04:36 PM)PhantomD Wrote: [ -> ]PHP should do it. Even though I have never done it myself, it will work.

Anybody know what PhantomD might mean or any other suggestions.  On the same note, where do you see all members of a group, like a page or link?
you can use View Groups plugin
(2015-03-04, 06:54 PM)user25 Wrote: [ -> ]On the same note, where do you see all members of a group, like a page or link?

AdminCP > Users & Groups: click Find Users

In "Is member of one or more of these user groups" select a group.

At bottom of page in "Display Options" enter number in "Results per page" field and click "Find Users" button.
(2015-03-04, 09:35 PM)Puppyite Wrote: [ -> ]
(2015-03-04, 06:54 PM)user25 Wrote: [ -> ]On the same note, where do you see all members of a group, like a page or link?

AdminCP > Users & Groups: click Find Users

In "Is member of one or more of these user groups" select a group.

At bottom of page in "Display Options" enter number in "Results per page" field and click "Find Users" button.

I meant for members on the front end.
<?php

global $db;

$query = "SELECT u.username, u.usergroup
FROM `".TABLE_PREFIX."users` u
JOIN  `".TABLE_PREFIX."usergroups` g ON u.usergroup = g.gid
WHERE g.gid = ".$usergroup_id.";";

$user_details = array();
while ($result = $db->fetch_array( $query )) {
    $user_details[$result['username']] = $result['usergroup'];
}

?>

This is the basic idea albeit it only checks primary right now. You would need NOT to do a join for the additional groups and use explode(',', $variable) to split the additional groups into individual gids. Then loop through with foreach to check. Edit the code as you see fit.
(2015-03-04, 11:57 PM)Ircher Wrote: [ -> ]
<?php

global $db;

$query = "SELECT u.username, u.usergroup
FROM `".TABLE_PREFIX."users` u
JOIN  `".TABLE_PREFIX."usergroups` g ON u.usergroup = g.gid
WHERE g.gid = ".$usergroup_id.";";

$user_details = array();
while ($result = $db->fetch_array( $query )) {
    $user_details[$result['username']] = $result['usergroup'];
}

?>

This is the basic idea albeit it only checks primary right now. You would need NOT to do a join for the additional groups and use explode(',', $variable) to split the additional groups into individual gids. Then loop through with foreach to check. Edit the code as you see fit.

Thanks Ircher, but I am a novice that does catch on pretty quick.  Where would I put the code (which page) and what would I use to call the code in the template. {$usergroup['uid']}?
(2015-03-05, 09:22 PM)user25 Wrote: [ -> ]
(2015-03-04, 11:57 PM)Ircher Wrote: [ -> ]
<?php

global $db;

$query = "SELECT u.username, u.usergroup
FROM `".TABLE_PREFIX."users` u
JOIN  `".TABLE_PREFIX."usergroups` g ON u.usergroup = g.gid
WHERE g.gid = ".$usergroup_id.";";

$user_details = array();
while ($result = $db->fetch_array( $query )) {
    $user_details[$result['username']] = $result['usergroup'];
}

?>

This is the basic idea albeit it only checks primary right now. You would need NOT to do a join for the additional groups and use explode(',', $variable) to split the additional groups into individual gids. Then loop through with foreach to check. Edit the code as you see fit.

Thanks Ircher, but I am a novice that does catch on pretty quick.  Where would I put the code (which page) and what would I use to call the code in the template. {$usergroup['uid']}?

I only gave a template for you to follow; further questions should be asked either in plugin development or theme development where you're more likely to get help on the subject. I recommend looking at the help doc article for templates & plugins.