Jump to the post that solved this thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 2 Years, 10 Months, 3 Weeks ago Get usergroup by id
#1
Solved: 2 Years, 10 Months, 3 Weeks ago
Hi!
How to get usergroup by id?
Reply
#2
Solved: 2 Years, 10 Months, 3 Weeks ago
<?php

define('IN_MYBB', 1);
define('THIS_SCRIPT', basename(__FILE__));
require_once './global.php';

// Read usergroup cache
$usergroupcache = $cache->read('usergroups');

// Usergroup array
$groups = array('4','3');

foreach($groups AS $validgroup)
{
	print($usergroupcache[ $validgroup ]['title'].'<br />');
}

Image:

[Image: mfpjjt.png]
Reply
#3
Solved: 2 Years, 10 Months, 3 Weeks ago
They're in ACP : 1 - 7

What goes around comes around



Reply
#4
Solved: 2 Years, 10 Months, 3 Weeks ago
No, it's about php code for developement plugin.
Reply
#5
Solved: 2 Years, 10 Months, 3 Weeks ago
(07-27-2016, 10:07 AM)adi19 Wrote: No, it's about php code for developement plugin.

My code will print the usergroups name specified in the $groups array.
Reply
#6
Solved: 2 Years, 10 Months, 3 Weeks ago
My bad! Not get usergroup by id group.
Get usergroup by id user (uid).
I have a array with uid and I want usergroup id by uid.
Reply
#7
Solved: 2 Years, 10 Months, 3 Weeks ago
(07-27-2016, 10:15 AM)adi19 Wrote: My bad! Not get usergroup by id group.
Get usergroup by id user (uid).
I have a array with uid and I want usergroup id by uid.

Ah. You can use this!

<?php

define('IN_MYBB', 1);
define('THIS_SCRIPT', basename(__FILE__));
require_once './global.php';

$uids = array('1','2','3','330'); // UID Array

foreach($uids AS $uid)
{
	$getinfo = get_user($uid);
	$group = $getinfo['usergroup'];
	print($group.'<br />');
}
Reply
#8
Solved: 2 Years, 10 Months, 3 Weeks ago
Hmm...yes, but I want a good complexity.
For good complexity, it's about query, but i dont know what is the query.
Reply
#9
Solved: 2 Years, 10 Months, 3 Weeks ago
The query is:
SELECT usergroup FROM mybb_users WHERE uid = variable_uid

with mybb code:
$result = $db->simple_select("users", "usergroup", "uid = {$uid}");
if($db->num_rows > 0) {
    $result = $db->fetch_array($result);
    $usergroup = $result['usergroup'];
}
[Image: ZbrcFs]
Reply
#10
Solved: 2 Years, 10 Months, 3 Weeks ago
Don't forget display_group and additional_groups!
Reply
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)