6
Quote:
tdickson wrote:
What is the correct syntax to use here?
if ($in_group) {
echo "User is in the group\n";
} else {
echo "User is not in the group\n";
}
if I am calling up group 1 how would it look?
for group2?
Well, here's Dave's code from that other post:
le="color: #000000"><?php // needed if inside a function global $xoopsUser, $xoopsModule; // true if current user has admin-right for current module $is_admin = is_object($xoopsUser) and is_object($xoopsModule) and $xoopsUser->isAdmin($xoopsModule->getVar('mid')); // array of IDs of groups to which current user belongs $member_handler =& xoops_gethandler('member'); $group_ids =& is_object($xoopsUser) ? $member_handler->getGroupsByUser($xoopsUser->getVar('uid')) : array(); // true if current user is in group ID #17 $in_group = in_array(17, $group_ids);
So therefore, for group 2, the code you'd need plus your conditional would be something like this:
le="color: #000000"><?php // array of IDs of groups to which current user belongs $member_handler =& xoops_gethandler('member'); $group_ids =& is_object($xoopsUser) ? $member_handler->getGroupsByUser($xoopsUser->getVar('uid')) : array(); if (in_array(2, $group_ids)) { echo "User is in group 2n"; } else { echo "User is not in group 2n"; }
Does that help? If you're not new to PHP, then that probably doesn't help and the problem/question is deeper than it appears.
--Julian