SSI check user is in secondary usergroup

Started by H, March 29, 2006, 03:17:51 PM

Previous topic - Next topic

H

There are many posts on the forum about checking if the user is logged in or is an admin/moderator.

However is there a way to see if a user is in a secondary usergroup?
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Thantos

Well it depends on a couple things:
Can that group ever be a primary group?
Do you want to exclude those who have that group as a primary group (if it can be primary)?


If the first is false (ie it can never be a primary group) or the first is true and the second is false then you can just use:
in_array(##, $user_info['groups']);

If the first is true and the second is true then you'll have to do a query

$res
= db_query("
 SELECT ID_MEMBER
 FROM
{$db_prefix}members
 WHERE ID_GROUP != ##
   AND ## IN (additionalGroups)
   AND ID_MEMBER=
$ID_MEMBER
 LIMIT 1"
, __FILE__, __LINE__);
if (
mysql_num_rows($res) == 0 )
 die(
"Go away you");
mysql_free_result($res);

H

-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Advertisement: