2012-12-08, 08:12 AM
(2012-12-08, 05:53 AM)Omar G. Wrote: [ -> ]You will need to get the users (UIDs) from that group (GIDs).
I feel like I'm missing something horribly obvious, but how would I do that?
(2012-12-08, 05:53 AM)Omar G. Wrote: [ -> ]You will need to get the users (UIDs) from that group (GIDs).
(2012-12-08, 08:12 AM)Seabody Wrote: [ -> ]Short example:(2012-12-08, 05:53 AM)Omar G. Wrote: [ -> ]You will need to get the users (UIDs) from that group (GIDs).
I feel like I'm missing something horribly obvious, but how would I do that?
//Fetch all users with usergroup, let's say 2, i.e. registered usergroup
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE `usergroup`= 2");
$uids_to_send_pm_to = array();
while($fetch = $db->fetch($query))
{
$uids_to_send_pm_to = $fetch['uid'];
}
//Now for $pm['toid'] field, you should use $uids_to_send_pm_to variable
$sender = -1; // MyBB Engine
$gid = 2;
switch($db->type)
{
case 'pgsql':
case 'sqlite3':
case 'sqlite2':
$sql = '\',\'||additionalgroups||\',\'';
break;
default:
$sql = 'CONCAT(\',\',additionalgroups,\',\')';
break;
}
$query = $db->simple_select('users', 'uid', 'usergroup=\''.$gid.'\' OR '.$sql.' LIKE \'%,'.$gid.',%\'');
$uids = array();
while($uid = $db->fetch_field($query, 'uid'))
{
$uids[(int)$uid] = 1;
}
sendPM('Hi!', 'This is a PM sent to you.', array_keys($uids), $sender)